答案 0 :(得分:0)
ECharts具有绘制多边形的API:
function renderItem(params, api) {
if (params.context.rendered) {
return;
}
params.context.rendered = true;
let points = [];
for (let i = 0; i < data.length; i++) {
points.push(api.coord(data[i]));
}
let color = api.visual('color');
return {
type: 'polygon',
shape: {
points: echarts.graphic.clipPointsByRect(points, {
x: params.coordSys.x,
y: params.coordSys.y,
width: params.coordSys.width,
height: params.coordSys.height
})
},
style: api.style({
fill: color,
stroke: echarts.color.lift(color)
})
};
}
var data = [
[
echarts.number.round(3.8),
echarts.number.round(4)
],
[
echarts.number.round(3.8),
echarts.number.round(4.5)
],
[
echarts.number.round(5),
echarts.number.round(6)
]
];
option = {
xAxis: {},
yAxis: {},
series: [
...other charts here ...
{
type: 'custom',
renderItem: renderItem,
data: data
}
]
};
结果如下: