echarts
echarts copied to clipboard
Series.custom.renderItem return BezierCurve will fill color in the whole area instead of being a Curve.
Version
5.0.0-alpha.2
Steps to reproduce
Just copy and paste these in any echarts online editor.
const colors = ["#1576d2", "#d14a82", "#26c1f2", "#a166ff", "#9C2BB6"] const radius = [0.7, 0.75] const data = [{ name: 'Mon', value: 35 }, { name: 'Tue', value: 35 }, { name: 'Wed', value: 35 }, { name: 'Thu', value: 35 }, { name: 'Fri', value: 35 }
] const sum = data.reduce((prev, curr) => { curr._start = prev curr._end = prev curr.value return curr._end }, 0)
function renderItem(params, api) { const ceilAngle = Math.PI / 100 // 装饰的显示角度 const coordSys = params.coordSys const coordRadius = coordSys.r const val = api.value(0) const index = api.value(1) const r0 = coordRadius * radius[0] const r = coordRadius * radius[1] const startAngle = (data[index]._start * Math.PI * 2) / sum - Math.PI / 2 const endAngle = (data[index]._end * Math.PI * 2) / sum - Math.PI / 2
const points = api.coord([api.value(0), api.value(1)]);
return {
type: "group",
children: [{
type: 'sector',
shape: {
cx: coordSys.cx,
cy: coordSys.cy,
r,
r0,
startAngle: startAngle,
endAngle: endAngle
},
style: api.style({
fill: colors[index],
opacity: 0.5
})
},
{
type: 'bezierCurve',
shape: {
x1: points[0],
y1: points[1],
x2: points[0] >= coordSys.cx ? points[0] 100 : points[0] - 100,
y2: points[1] >= coordSys.cy ? points[1] 100 : points[1] - 100,
cpx1: points[0] >= coordSys.cx ? points[0] 50 : points[0] - 50,
cpy1: points[1] >= coordSys.cy ? points[1] 60 : points[1] - 60,
cpx2: points[0] >= coordSys.cx ? points[0] 50 : points[0] - 50,
cpy2: points[1] >= coordSys.cy ? points[1] - 60 : points[1] 60,
percent: 1
},
style: ({
fill: colors[index],
})
}]
}
}
option = { color: colors, angleAxis: { type: 'category', show: true, }, radiusAxis: { show: true }, polar: { radius: "75%" }, series: [{ type: 'custom', data: data, renderItem: renderItem, coordinateSystem: 'polar' }] }
What is expected?
So basically the renderItem is supposed to print 5 different BezierCurves with different angles.
What is actually happening?
The Bezier curve requires 8 variables: x1, y1, x2, y2, cpx1, cpy1, cpx2, cpy2. These 4 points declare one Bezier curve, but here they were recognized by the renderItem as an area instead of a curve.
I was asked to change the Pie chart's labelLine from default to the Bezier Curves. I was trying to edit the source code and it worked perfectly. However, the build function was not working well, so I cannot run the build command and pack it up after editing. Thus, I have to draw this pie chart by custom series.
Would that be another option if I submit my source code version with an additional labelLine.isBezier API? Will the Echarts developers review and merge my function into the source code? How fast it can be?
Hi! We've received your issue and please be patient to get responded. 🎉 The average response time is expected to be within one day for weekdays.
In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.
If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to [email protected]. Please attach the issue link if it's a technical questions.
If you are interested in the project, you may also subscribe our mail list.
Have a nice day! 🍵
Try stroke
instead of fill
please.
This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.
This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!