Last active
December 29, 2017 01:19
-
-
Save jaehyeon-kim/224e0b0fa023abcf1f35640dfc725f05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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