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
library("scales")
library("highcharter")
## Generate a random data set with roughly 4,000 lines
df <- as.data.frame(cbind(x = seq(1:3900),
a1 = rnorm(3900, 1000000, 2000000),
a2 = abs(rnorm(3900, 1000000, 2000000)),
a3 = rnorm(3900, 20000, 30000),
a4 = rnorm(3900, 1000, 500),
a5 = rnorm(3900, 0.01, 0.02)))
head(df)
## x a1 a2 a3 a4 a5
## 1 1 808424.8 1950682.3 63248.037 617.2346 0.001998904
## 2 2 -2749506.0 779605.2 10470.694 633.5657 0.026749689
## 3 3 3344446.4 2668204.4 26961.184 1406.6373 -0.013224029
## 4 4 -130381.4 196934.8 -9890.199 851.5980 -0.015904223
## 5 5 2436734.7 488687.7 -7053.098 1569.1003 0.019962196
## 6 6 1027284.6 2531999.0 32778.007 201.2629 0.030396286
## Modify the data set to assign colors to each bar based on the values
## of a3. Green bars signify positive a3's and red bars signify
## negative a3's
df <- df %>%
mutate(a6 = cumsum(a3)) %>%
mutate(color = ifelse(a3 > 0,
"rgba(0,0,250,0.6)",
"rgba(250,0,0,0.6)")) %>%
mutate(y = a1,
a1 = comma_format()(round(a1, 0)),
a3 = comma_format()(round(a3, 0)),
a4 = comma_format()(round(a4, 4)),
a5 = comma_format()(round(a5, 0)),
a6 = comma_format()(round(a6, 0))
) %>% tbl_df()
input <- lapply(unname(split(df, seq(nrow(df)))), as.list)
input <- list.parse3(df)
highchart2() %>%
hc_title(text = "Not so slow chart ;)") %>%
hc_subtitle(text = "Thanks boost module") %>%
hc_chart(zoomType = "x", animation = FALSE, type = "column") %>%
hc_plotOptions(series = list(turboThreshold = 4000)) %>%
hc_add_serie(data = input)