Search code examples
rhighchartsr-highcharter

R - Highcharts compare option


Is there a way to use the compare function in high charts when using them in R

As in:

https://www.highcharts.com/stock/demo/compare


Solution

  • Yes, it's simple. Just define it in your series options or plotOptions. Here is an example code:

    library(highcharter)
    
    highchart(type = 'stock') %>% 
      hc_add_series(data = c(2, 3, 4, 5, 5, 4, 5, 6, 7, 6, 5), compare = 'percent')
    

    And here pure JS showing the same: https://jsfiddle.net/BlackLabel/156yLqw9