如何为交互式条形图创建重置按钮?

时间:2018-12-27 13:06:16

标签: shiny

我想为使用'ECharts2shiny'程序包创建的条形图创建一个重置按钮。 通过单击重置按钮,它应该显示默认的条形图。

我有此代码:

library(shiny)
library(ECharts2Shiny)

# Prepare sample data for plotting --------------------------
dat <- data.frame(c(10, 20, 30),
              c(20, 30, 40),
              c(30, 40, 50),
              c(40, 50, 60))
names(dat) <- c("Poor", "rich", "Male", "Female")
row.names(dat) <- c("year1", "year2", "year3")

# Server function -------------------------------------------
server <- function(input, output) {
# Call functions from ECharts2Shiny to render charts
renderBarChart(div_id = "test", grid_left = '1%', direction = "vertical",
             data = dat)
}

# UI layout -------------------------------------------------
ui <- fluidPage(
# We MUST load the ECharts javascript library in advance
loadEChartsLibrary(),

tags$div(id="test", style="width:50%;height:400px;"),
deliverChart(div_id = "test")
)

# Run the application --------------------------------------
shinyApp(ui = ui, server = server)

请问有人可以创建可以将条形图更改为默认选择的重置按钮的代码吗?

谢谢。selective bar chart

0 个答案:

没有答案