inst/app-visualize/helper/highline.R

library(highcharter)
# title
# subtitile
# axis
# legend
# plotoptions


# gdp <- readr::read_csv('gdp.csv')

highline <- function(data, x, columns, add_labels = FALSE) {
  
  x <- data %>%
    select_(x) %>%
    pull(1)
  
  column <- data %>%
    select(columns)
  
  n <- column %>% ncol() %>% seq_len()
  
  nam <- column %>% names()
  
  h <- highchart() %>%
    hc_xAxis(categories = x)
  
  for (i in n) {
    h <- h %>%
      hc_add_series(name = nam[i], data = column[[i]])
  }
  
  if (add_labels) {
    h %>%
      hc_plotOptions(line = list(dataLabels = list(enabled = TRUE)))
  }
  
  h
  
}

# highline(gdp, 'year', c('india', 'china'), add_labels = TRUE)

Try the xplorerr package in your browser

Any scripts or data that you put into this service are public.

xplorerr documentation built on Feb. 28, 2019, 5:05 p.m.