Change names of the data with proxy
Examples
if (interactive()) {
library(shiny)
library(billboarder)
ui <- fluidPage(
tags$h2("Update axis title & data name (tooltip & legend)"),
billboarderOutput(outputId = "my_bb"),
textInput(
inputId = "new_name",
label = "New name :",
value = "this is a new name",
width = "100%"
),
actionButton(
inputId = "update",
label = "Update chart",
width = "100%"
)
)
server <- function(input, output, session) {
output$my_bb <- renderBillboarder({
dat <- sample(letters[1:5], 100, TRUE)
billboarder() %>%
bb_barchart(data = table(dat)) %>%
bb_y_axis(label = list(text = "Freq"))
})
observeEvent(input$update, {
dat <- sample(letters[1:5], 100, TRUE)
billboarderProxy(shinyId = "my_bb") %>%
bb_proxy_axis_labels(y = input$new_name) %>%
bb_proxy_data_names(old = "Freq",
new = input$new_name) %>%
bb_barchart(data = table(dat))
}, ignoreInit = TRUE)
}
shinyApp(ui, server)
}