需求:
在如图所示纵坐标添加点击事件,跳转到其他页面
方法:
(1)定义点击事件
var ecConfig = echarts.config.EVENT;
myChart.on(ecConfig.CLICK, eConsole);
(2)设置对应坐标的点击位置
clickable:true即可
yAxis: [
{
type: 'category',
name: '类别',
axisLabel: {
show: true,
clickable:true,
textStyle: {
fontSize: 11
}
},
splitLine: {
show: false
},
splitArea: {
show: false
},
data: eventType.reverse()
}
],
(3)获取点击时的数据,进行相应跳转
function eConsole(param) {
if (typeof param.seriesIndex == 'undefined') {
return;
}
if (param.type == 'click') {
alert(param.data+1);
window.location =...
}
}