在散点图基础上增加第三维度(气泡大小),展示三个变量之间的关系
new Scatter('chart-basic', {
data,
xField: 'price',
yField: 'sales',
sizeField: 'profit',
size: [8, 30], // 减小最大气泡尺寸,防止溢出
colorField: 'category',
color: ['#5B8FF9', '#5AD8A6', '#FF9500'],
shape: 'circle',
pointStyle: {
fillOpacity: 0.6,
stroke: '#fff',
lineWidth: 1
},
padding: [40, 80, 50, 50], // 右侧大幅增加空间,防止X轴标签和大气泡溢出
meta: {
price: { range: [0.12, 0.88] }, // 缩小映射范围,确保气泡不紧贴边缘
sales: { range: [0.12, 0.88] },
},
xAxis: {
label: { style: { fontSize: 11, fill: '#1D1D1F' } },
line: { style: { stroke: '#E8E8ED' } },
tickLine: null,
},
yAxis: {
label: { style: { fontSize: 11, fill: '#1D1D1F' } },
grid: { line: { style: { stroke: '#E8E8ED', lineDash: [4, 4] } } },
line: null,
},
legend: false,
tooltip: {
fields: ['product', 'price', 'sales', 'profit'],
},
}).render();
| 参数 | 值 | 说明 |
|---|---|---|
sizeField |
string | 气泡大小映射字段(关键) |
size |
[8, 35] |
气泡大小范围 [最小, 最大] |
colorField |
string | 颜色分组字段 |
shape |
circle |
气泡形状(通常为圆形) |
pointStyle.fillOpacity |
0.6 |
气泡填充透明度 |
pointStyle.stroke |
#fff |
气泡边框颜色 |
pointStyle.lineWidth |
1 |
气泡边框宽度 |
| 建议 | 说明 |
|---|---|
| 数据维度 | 气泡图可展示三个维度:X轴、Y轴、大小,可选颜色作为第四维度 |
| 大小范围 | 建议大小范围比例不超过 1:5,确保视觉差异明显但不过度 |
| 透明度 | 建议 0.5-0.7,确保重叠时仍可识别 |
| 适用场景 | 适合展示多维度数据关系,如价格-销量-利润分析 |