rCharts - Hide all series EXCEPT selected series from legend

不问归期 提交于 2019-12-11 04:37:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!