rm(list = ls())
library("rCharts")
library("highcharter")
library("dplyr")
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
chart.data <- readRDS("~/../Downloads/example.rds")
chart.daily <- chart.data
head(chart.daily)
## date group USD ymin ymax yearmon month year week
## 306 1.446422e+12 Actual 13064758 0 0 1.446336e+12 November 2015 45
## 307 1.446509e+12 Actual 12556833 0 0 1.446336e+12 November 2015 45
## 308 1.446595e+12 Actual 12255043 0 0 1.446336e+12 November 2015 45
## 309 1.446682e+12 Actual 11801719 0 0 1.446336e+12 November 2015 45
## 310 1.446768e+12 Actual 10606744 0 0 1.446336e+12 November 2015 45
## 311 1.446854e+12 Actual 11544700 0 0 1.446336e+12 November 2015 45
cnl <- "Australia"
f.horizon <- "7"
# rCharts
# hc <- Highcharts$new()
# hc$title(text = paste0(as.character(f.horizon), "-Day Forecast for ", cnl))
# hc$yAxis(title = list(text = "USD"))
# hc$xAxis(type = 'datetime')
# hc$series(
# data = toJSONArray2(chart.daily[chart.daily$group=="Actual", c('date', 'USD')], names = F, json = F),
# type = 'line',
# zIndex = 1,
# color = 'LightSkyBlue', # #87CEFA; http://www.w3schools.com/html/html_colornames.asp
# name = "Actual"
# )
# hc$series(
# data = toJSONArray2(chart.daily[chart.daily$group=="Forecast", c('date', 'USD')], names = F, json = F),
# type = 'line',
# zIndex = 1,
# color = 'orange',
# name = "Point Forecast"
# )
# hc$series(
# data = toJSONArray2(chart.daily[chart.daily$group=="Forecast", c('date', 'ymin', 'ymax')], names = F, json = F),
# type = 'arearange',
# fillOpacity = 0.3,
# lineWidth = 0,
# color = '#87CEFA', # does not work with Color Names
# name = "80% Confidence Interval",
# zIndex = 0
# )
# hc$plotOptions(line = list(marker = list(radius = 0)))
# hc$chart(zoomType = "x")
# hc$exporting(enabled=T, buttons=list(contextButton = list(align = 'right', verticalAlign = 'top')))
# hc
# Highcarter
highchart(highstock = TRUE) %>%
hc_title(text = paste0(as.character(f.horizon), "-Day Forecast for ", cnl)) %>%
hc_xAxis(title = list(text = "USD"),
type = "datetime") %>%
hc_add_serie(data = chart.daily %>% filter(group == "Actual") %>%
select(date, USD) %>% list.parse2(),
zIndex = 1,
color = 'LightSkyBlue', # #87CEFA; http://www.w3schools.com/html/html_colornames.asp
name = "Actual") %>%
hc_add_serie(data = chart.daily %>% filter(group == "Forecast") %>%
select(date, USD) %>% list.parse2(),
zIndex = 1,
color = 'orange', # #87CEFA; http://www.w3schools.com/html/html_colornames.asp
name = "Point Forecast") %>%
hc_add_serie(data = chart.daily %>% filter(group == "Forecast") %>%
select(date, ymin, ymax) %>% list.parse2(),
type = 'arearange',
fillOpacity = 0.3,
lineWidth = 0,
color = '#87CEFA', # does not work with Color Names
name = "80% Confidence Interval",
zIndex = 0) %>%
hc_plotOptions(zoomtype = "x") %>%
hc_exporting(enabled = TRUE)
## Warning: 'hc_add_serie' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")
## Warning: 'hc_add_serie' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")
## Warning: 'hc_add_serie' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")