title: How to select multiple series in the legend - highchart - javascript
body: <p>I would like to select multiple series in the legend like <a href="https://jsfiddle.net/t2MxW/21971/" rel="nofollow noreferrer">here</a>.</p>
  
  <p>With help, I succeed to create the same thing on R but it doesn't allowed to select more than one serie at a time.</p>
  
  <p>Because I'm on R, I use the shinyjs package. The javascript code is in jsCode.</p>
  
  <p>The code :</p>
  
  <pre><code>library(highcharter)
  library(shiny)
  library(shinydashboard)
  
  data_plot &lt;- data.frame(categories = c("A", "B", "C", "D"),
                          serie1 = c(1563, 1458, 205, 695),
                          serie2 = c(562, 258, 17, 115),
                          serie3 = c(324, 654, 23, 987),
                          serie4 = c(123, 567, 234, 12),
                          serie5 = c(376, 88, 98, 123)
  )
  
  jsCode &lt;- JS("function(event) {
  if (!this.visible )
  return false;
  
  var seriesIndex = this.index;
  var series = this.chart.series;
  
  for (var i = 0; i &lt; series.length; i++)
  {
  if (series[i].index != seriesIndex)
  {
  series[i].visible ?
    series[i].hide() :
    series[i].show();
  } 
  }
  return false;
  }")
  
  ui &lt;- dashboardPage(
  
  
    dashboardHeader(title = "My Dashboard"),
  
    dashboardSidebar(),
  
    dashboardBody(  
  
      highchartOutput ("hc1")))
  
  server &lt;- function(input, output,session) {
  
    #Normal Chart
    output$hc1 &lt;- renderHighchart ({
      Hch &lt;- highchart(hcaes(x = Spring ,y = Ponctuation)) %&gt;% 
        hc_title(text = "Graph",
                 margin = 20, align = "left",
                 style = list(color = "#FE8000", useHTML = TRUE)) %&gt;% 
        hc_xAxis(categories = data_plot$categories, title = list(text = "Number 
   of spring",color = "#FE8000")) %&gt;%
        hc_yAxis(title = list(text = "Result", color = "#FE8000"))%&gt;% 
        hc_add_series(name = 'serie1', data = data_plot$serie1) %&gt;% 
        hc_add_series(name = 'serie2', data = data_plot$serie2)%&gt;% 
        hc_add_series(name = 'serie3', data = data_plot$serie3)%&gt;% 
        hc_add_series(name = 'serie4', data = data_plot$serie4)%&gt;% 
        hc_add_series(name = 'serie5', data = data_plot$serie5) %&gt;% 
        hc_plotOptions(series = list(events = list(legendItemClick = jsCode)))
  
      Hch})
  }
  shinyApp(ui, server)
  </code></pre>