问题
I like to do the reversal of the default logic. When I click on a series in the legend, I would like to hide all series except the selected one. I know I have to use JS for this. The solutions I found did not work for me.
I found this solution but when I modify my code for R like this:
legendItemClick = "#! function(event) {
if (!this.visible)
return false;
var seriesIndex = this.index;
var series = this.chart.series;
for (var i = 0; i < series.length; i++)
{
if (series[i].index != seriesIndex)
{
series[i].visible ?
series[i].hide() :
series[i].show();
}
}
return false;
} !#"
However, that does not work and no plot is showing at all. How do I have to modify the code from fiddle so it works within R using rChart/Highcharts?
来源:https://stackoverflow.com/questions/52504678/rcharts-hide-all-series-except-selected-series-from-legend