是否可以将数据表与highcharter链接?例如,单击表格的任何行,高位图表将以动态方式显示结果?
答案 0 :(得分:0)
这里是一个示例,选择所需的任何行,然后查看图表(高图)对所选值的反应:
library(highcharter)
library(DT)
library(shiny)
db <- mtcars
ui <- fluidPage(DTOutput("my_dt"),
highchartOutput("my_hc"))
server <- function(input, output, session) {
output$my_dt <- renderDT({
db
})
output$my_hc <- renderHighchart({
db_hc <-
db[input$my_dt_rows_selected, ] # filter dataset according to select rows in my_dt
hc <- highchart() %>%
hc_add_series(name = "mpg", data = db_hc$mpg) %>%
hc_add_series(name = "wt", data = db_hc$wt)
hc
})
}
shinyApp(ui, server)
希望有帮助!