Skip to content

Instantly share code, notes, and snippets.

@jaehyeon-kim
Last active December 29, 2017 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaehyeon-kim/224e0b0fa023abcf1f35640dfc725f05 to your computer and use it in GitHub Desktop.
Save jaehyeon-kim/224e0b0fa023abcf1f35640dfc725f05 to your computer and use it in GitHub Desktop.
library(magrittr)
library(dplyr)
library(highcharter)
library(shiny)
path <- 'C:/workspace/waterfall/waterfall.csv'
get_waterfall <- function(path) {
colors <- c("#d35400", "#2980b9", "#2ecc71", "#f1c40f", "#2c3e50", "#7f8c8d")
path <- 'C:/workspace/waterfall/waterfall.csv'
df <- read.csv(path, stringsAsFactors = FALSE)
df <- df %>% mutate(name = paste(YearMonth, status),
color = rep(colors, length.out = nrow(df)),
y = value) %>%
select(name, y, color)
highchart() %>%
hc_title(text = 'waterfall', style = list(fontSize = "15px")) %>%
hc_chart(type = 'waterfall') %>%
hc_xAxis(categories = df$name) %>%
hc_add_series(df, name = 'series name', showInLegend = TRUE)
}
# Define the UI
ui <- bootstrapPage(
highchartOutput('QtyLeaksOpenClose_plot')
)
# Define the server code
server <- function(input, output) {
output$QtyLeaksOpenClose_plot <- renderHighchart({
get_waterfall(path)
})
}
# Return a Shiny app object
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment