ECharts点击横坐标事件实现超链接跳转

需求:微博排行榜,横坐标展示出了微博对应的id,现在需要通过点击横坐标来实现跳转到对应的微博页面。


  1. 设置横坐标中的triggerEvent属性为true;
xAxis: {
  ...
  triggerEvent: true,
  ...
},
  1. 添加on点击事件。
thisChart.on("click" ,function (params) {
  window.location.href = "https://m.weibo.cn/detail/" + params.value;
});

最终结果:符合预期。

posted @ 2023-06-02 10:20  Shineloner  阅读(751)  评论(0)    收藏  举报