How can I fire event on click line (not dots) on line chart using Echarts.
This code fires only if I click the dot on chart
myChart.on('mouseup', function (params) {
console.log(params);
});
Do you now any other library where it is possible?
How can I fire event on click line (not dots) on line chart using Echarts.
This code fires only if I click the dot on chart
myChart.on('mouseup', function (params) {
console.log(params);
});
Do you now any other library where it is possible?
2
Answers
Need to add to
triggerLineEvent: true
in seriesECharts doesn’t provide a built-in event for clicking on a line itself in a chart. The interaction events are usually associated with dots on the chart.
You have basically two options. You can do a workaround by adding invisible data points along the line at regular intervals and then binding click events to those invisible data points. This would create an illusion of clicking the line itself. Or you can switch to a totally different library. D3.js is a highly flexible library that allows you to create custom visualizations with more control over events. However, it also has a steeper learning curve compared to libraries like ECharts.
Edit:
Here is also my most minimal example of how you could achieve this with D3.js
https://jsfiddle.net/kwbfxjau/