我见过https://www.amcharts.com/docs/v4/concepts/event-listeners/和https://www.amcharts.com/docs/v4/reference/categoryaxis/#Events
categoryAxis.events.on('hit', function (ev) {
console.log('clicked on ', ev.target)
}, this)
工作。但是,这将返回完整的CategoryAxis。我想区分一下用户点击了哪个catgeory。
例如categoryAxis.category.template.events.on('hit',function(ev(不存在。
您需要在轴渲染器的标签模板上添加命中事件侦听器,以便捕获单击的类别标签:
categoryAxis.renderer.labels.template.events.on('hit', function(ev) {
alert(ev.target.dataItem.category)
})