Search code examples
rr-highcharter

Remove series from legend only


Looking for a way to remove a label from the legend but keep the line on the chart.

for example the appending of 'visible = FALSE' removes the line from the chart as well as from the legend.

highchart() %>% 
    hc_add_series(df, "line",hcaes(date, value)) %>% 
    hc_xAxis(
      title = list(text = "Year"),
      type = "date",
      tickInterval = 2) %>% 
    hc_add_series(
      name = "Monthly Moving Average",
      moving_avg_df, 
      "line", 
      hcaes(date, value)) %>% 
    hc_yAxis(
      title = list(text = "Totals")
    ) %>% 
    hc_legend(align = 'left')

enter image description here


Solution

  • You need to add the option showInLegend = FALSE to the hc_add_series(...) term if you don't want the series to show in the legend (the default is to show it).