Reputation: 501
I am building Highcharts within R by using rCharts library. But I think anyone who is familiar with Javascript or Highcharts could answer my question as well. I incorporated a function to allow user to ctrl+click to select a specific series.
Please see this for your reference: https://jsfiddle.net/derekrezek/Nkeep/109/
a$plotOptions(
series = list(
events = list(
legendItemClick = "#! function(e) {
var hideAllOthers = e.browserEvent.metaKey|| e.browserEvent.ctrlKey;
if (hideAllOthers) {
var seriesIndex = this.index;
var series = this.chart.series;
for (var i = 0; i < series.length; i++) {
if (series[i].index === seriesIndex) {
if (!series[i].visible) series[i].setVisible(true, false);
} else {
if (series[i].visible) series[i].setVisible(false, false);
}
}
this.chart.redraw();
return false;
}} !#")
)
)
It doesn't impact original functionality of Highcharts and allow user to select a specific series by ctrl+click the legend item. However, what if I have 50+ legends. After I select one specific series and then I want the all other series back, I will have to click all of invisible series to show them again, which is not practical.
Anyone knows how to make a reset button? or allow user to ctrl+click again to restore the original graph?
Thank you in advance!
Upvotes: 1
Views: 101