'How to invert the legend's on-click--behavior on XY chart in amcharts4?
I have this issue. The default behavior of XY amchart is to load all data, and on legend click - hide the current selection. Is it possible to revert this behavior? Like, if I select a legend- to hide all the other elements from the chart and leave the current selection.
Solution 1:[1]
The grammar may be strange with the help of a translator because of the weak English.
chart.legend.itemContainers.template.togglable = false;
The code above deactivates the basic behavior of the legend.
chart.legend.itemContainers.template.events.on("hit", function(ev) {
let targetName = ev.target.dataItem.dataContext.name;
chart.series.each(function (item) {
if(targetName != item.name){
item.disabled = true;
}
});
});
The code above is an event when you click the legend.
I don't know if it's the answer you want, but I wrote it down...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Raccoon Dog |
