xiaoliang055 opened a new issue, #20679:
URL: https://github.com/apache/echarts/issues/20679
### What problem does this feature solve?
在线示例上面执行:
option = {
title: {
text: '饼图 + Custom 动态标记',
left: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
left: 'left'
},
series: [
{
name: '访问来源',
type: 'pie',
radius: ['40%', '70%'],
center: ['50%', '50%'],
data: [
{ value: 40, name: '搜索引擎' },
{ value: 30, name: '直接访问' },
{ value: 20, name: '邮件营销' },
{ value: 10, name: '联盟广告' }
]
},
{
type: 'custom',
renderItem: function (params, api) {
const dataIndex = params.dataIndex; // 当前数据索引
const value = api.value(0); // 获取当前值
// 饼图中心点和半径
const center = [250, 250];
const radius = 150;
// 计算当前扇区的角度
const angle = (dataIndex / 4) * 360; // 根据索引计算角度
const radian = (angle * Math.PI) / 180;
// 计算点的位置
const x = center[0] + Math.cos(radian) * (radius + 10); // X
坐标
const y = center[1] + Math.sin(radian) * (radius + 10); // Y
坐标
// 绘制圆点
return {
type: 'circle',
shape: {
cx: x,
cy: y,
r: 5
},
style: {
fill: 'red'
}
};
},
data: [0, 1, 2, 3]
}
]
};
报错:
failed to run code TypeError: Cannot read properties of undefined (reading
'get')
at yx (echarts.min.js:45:244981)
at cartesian2d (echarts.min.js:45:243919)
at echarts.min.js:45:246420
at _x (echarts.min.js:45:246457)
at e.getInitialData (echarts.min.js:45:667961)
at e.init (echarts.min.js:45:160442)
at e.<anonymous> (echarts.min.js:45:114767)
at Array.forEach (<anonymous>)
at E (echarts.min.js:35:5077)
at e.<anonymous> (echarts.min.js:45:114400)
如果不加custom 就不会报错,如果是柱状图bar也不会报错。
### What does the proposed API look like?
需要能给出pie中使用自定义custom的方式
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]