jbkunst / highcharter

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

impose xts data in navigator #33

Closed thomasbrand closed 8 years ago

thomasbrand commented 8 years ago

hi,

I took the standard xts example :

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

hc <- highchart(type = "stock") %>% 
  hc_add_series_xts(usdjpy, id = "usdjpy") %>% 
  hc_add_series_xts(eurkpw, id = "eurkpw")

Now I want to impose in the navigator below the chart a third xts series

eurusd <- getSymbols("EUR/USD", src = "oanda", auto.assign = FALSE)

How can I reproduce this example : http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/stock/navigator/series-data/ in highcharter ?

Thanks a lot for the wonderful package!

jbkunst commented 8 years ago

Hi @thomasbrand ,

You can do manually.

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

hc <- highchart(type = "stock") %>% 
  hc_add_series_xts(usdjpy, id = "usdjpy") %>% 
  hc_add_series_xts(eurkpw, id = "eurkpw")

hc

eurusd <- getSymbols("EUR/USD", src = "oanda", auto.assign = FALSE)

Explore the hc_add_series_xts function

timestamps <- datetime_to_timestamp(time(eurusd))
ds <- list.parse2(data.frame(timestamps, as.vector(eurusd)))

Look the similarities between the original example data https://www.highcharts.com/samples/data/three-series-1000-points.js and the ds object.

hc %>% 
  hc_navigator(series = list(data = ds))

Thank you for use the package.

thomasbrand commented 8 years ago

Perfect, thanks a lot!