jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
720 stars 149 forks source link

how to add legend to `xts` #187

Closed changshun closed 8 years ago

changshun commented 8 years ago

Hi @jbkunst ,

I try to use hc_legend to add legend to hc_add_series_xts plot, but it did not work

jbkunst commented 8 years ago

Hi @changshun ,

Can you put some code please? Have you tried hc_legend(enabled = TRUE).

hc_add_series_xts change the type to stock which uses highstock which disable legends by default.

library("quantmod")

usdjpy <- getSymbols("USD/JPY", src="oanda", auto.assign = FALSE)
eurkpw <- getSymbols("EUR/KPW", src="oanda", auto.assign = FALSE)

highchart(type = "stock") %>% 
  hc_add_series_xts(usdjpy, id = "usdjpy", name = "USD/JPY") %>% 
  hc_add_series_xts(eurkpw, id = "eurkpw") %>% 
  hc_legend(enabled = TRUE)

Finally, I use github issues mainly to report bug or ask features ;) https://github.com/jbkunst/highcharter/blob/master/CONTRIBUTING.md. You can ask in stackoverflow, I take a look sometimes the [r] [highcharts] tags :wink: