echarts3 的雷达图在触发click 事件后,获得的 params 中 无法获取 indicator 信息(同#4462)
问题简述 (One-line summary) (同#4462)
echarts3 的雷达图在触发click 事件后,获得的 params 中 无法获取 indicator 信息
版本及环境 (Version & Environment)
ECharts 版本 (ECharts version):3.3.1 浏览器类型和版本 (Browser version): chrome 版本 54.0.2840.71 m 操作系统类型和版本 (OS Version): win7 重现步骤 (Steps to reproduce)
代码
option = {
title: {
text: '基础雷达图'
},
tooltip: {},
legend: {
data: ['预算分配(Allocated Budget)', '实际开销(Actual Spending)']
},
radar: {
// shape: 'circle',
indicator: [
{ name: '销售(sales)', max: 6500},
{ name: '管理(Administration)', max: 16000},
{ name: '信息技术(Information Techology)', max: 30000},
{ name: '客服(Customer Support)', max: 38000},
{ name: '研发(Development)', max: 52000},
{ name: '市场(Marketing)', max: 25000}
]
},
series: [{
name: '预算 vs 开销(Budget vs spending)',
type: 'radar',
// areaStyle: {normal: {}},
data : [
{
value : [4300, 10000, 28000, 35000, 50000, 19000],
name : '预算分配(Allocated Budget)'
},
{
value : [5000, 14000, 28000, 31000, 42000, 21000],
name : '实际开销(Actual Spending)'
}
]
}]
};
myChart.on('click', function (params) {
// 控制台打印数据的名称
console.log(params);
});
2.点击 图例上的点,获得如下 params image
期望结果 (Expected behaviour)
根据上图,可见:name 中放的 是 legend 信息,而在echarts2 中,name 放的是 indicator 信息。 legend 信息已经存在于 data.name 了,没必要 放在 name 属性中。现在的情况是,无论点击某一个图例上的任何一个点,返回的 params 都是一样的
遇到了同样问题 按理说dataIndex应该返回indicator的index,但无论选择任何点dataIndex都是0
遇到同样问题 dataIndex永远是0,而且没有indicator的信息
同样的问题,有解决么?
同样的问题,有解决么?
同樣的問題,有解決麼?
2年了。
dataIndex的不同值只有图表事件里才有. 点击雷达图表, 对应相应的dataIndex. indicator中的name相应的索引至今没有解决, 一直是默认的0, 所有小伙伴如果想要通过点击indicator中的name实现跳转的, 目测只能通过对name值的比对才可以, 类似如:
// 增加 indictor name 点击事件
chart1.on('click', function (params) {
console.log("name: ",params.name) // 点击事件获取的name值
if (params.name == "上海") {
window.open("#上海")
} else if(params.name == "广东") {
window.open("#广东")
}
或者:
let newRedirectArray = [
{
"name": "上海",
"id": 1
},
{
"name": "广东",
"id": 2
}
]
// 点击获取的 indictor name和原数组进行比较, 匹配跳转相应的链接
newRedirectArray.map(item =>
params.name == item.name
? window.open("https:baidu.com=" + item.id)
: ""
);
如果想对name进行相应的文字换行, 直接操作, "\n"即可, 如:
{
name: '上海\n详情',
max: 100,
color: "#42dcaf"
}
This issue has been automatically marked as stale because it has not had 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!