Skip to content

Commit

Permalink
updated shiny example
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 25, 2024
1 parent 753fa04 commit 683f0dc
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions examples/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ui <- page_fluid(
radioButtons(
inputId = "data",
label = "Show:",
choiceNames = c("electricity mix by country", "coutries generation by sources"),
choiceNames = c("electricity mix by country", "countries generation by sources"),
choiceValues = c("mix", "sources"),
inline = TRUE
),
Expand Down Expand Up @@ -56,32 +56,26 @@ server <- function(input, output, session) {
mapping <- aes(country, generation, fill = country)
}

vc <- vchart(elec_data, mapping = mapping)
if (input$type == "bar") {
vc <- vbar(elec_data, mapping) %>%
vc <- vc %>%
v_bar(serie_id = "bar_serie") %>%
v_specs_legend(visible = FALSE) %>%
v_specs(
xField = "x",
label = list(visible = input$show_label)
)
} else if (input$type == "pie") {
vc <- vpie(elec_data, mapping, serie_id = "pie"
) %>%
v_specs(
label = list(visible = input$show_label),
serie = "pie"
serie_id = "bar_serie"
)
} else if (input$type == "pie") {
vc <- vc %>%
v_pie(label = list(visible = input$show_label))
} else if (input$type == "treemap") {
vc <- vtreemap(elec_data, mapping) %>%
v_specs(
label = list(visible = input$show_label)
)
vc <- vc %>%
v_treemap(label = list(visible = input$show_label))
} else if (input$type == "circlepacking") {
vc <- vcirclepacking(elec_data, mapping) %>%
v_specs(
label = list(style = list(visible = input$show_label))
)
vc <- vc %>%
v_circlepacking(label = list(style = list(visible = input$show_label)))
}

vc %>%
v_scale_color_manual(c(
"oil" = "#80549f",
Expand Down

0 comments on commit 683f0dc

Please sign in to comment.