This is my code.
My question is: Is it possible to make shiny update/refresh the chart displayed in item 3 panel (Menu Item 3) once I click on it? I know that I could use a button, for example. But I need to click on Item 3 and force the page to refresh once I click.
I was wondering if observeEvent would do this for me.
library("shiny")
library("shinyWidgets")
library("gapminder")
hc_data_1 <- gapminder %>% filter(country == 'Chile')
ui <- dashboardPage(dark = FALSE,fullscreen = TRUE,
dashboardHeader(title = h4("Title")),
dashboardSidebar(skin = 'light',
sidebarMenu( id = "sidebarMenu",
menuItem(text = "Item 1",
tabName = "panel_1"),
menuItem(text = "Item 2",
tabName = "panel_2"),
menuItem(text = "Item 3",
tabName = "panel_3") )
),
dashboardBody(
tabItems(
tabItem(tabName = 'panel_1',
tabPanel("Panel 1")),
tabItem(tabName = 'panel_2',
tabPanel("Panel 2")),
tabItem(tabName = 'panel_3',
tabPanel("Panel 3",
htmlOutput('chart_1',width = '100px')
))
)
))
server <- function(input, output, session) {
output$chart_1<- renderUI({
hc_data_1 %>%
hchart(
"line",
hcaes(x = year, y = pop),
showInLegend = TRUE,
color = "#63696b",
name = "chile-argentina"
)
})
}
shinyApp(ui = ui, server = server)