Reputation: 31
Is it possible to link datatable with highcharter? For example, click on any line of the table, the highcharter will show result in dynamic?
Upvotes: 0
Views: 555
Reputation: 481
Here is an example, select any row you want and see the chart (highchart) react to selected values:
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)
Hope it helps!
Upvotes: 1