I want the charts to show the animation every time you click on a tab, not just the first. Here's what I got:
library(echarts4r)
library(magrittr)
ui <- fluidPage(
tabsetPanel(id = "tabsetpanel",
tabPanel("Panel A", value = "A", echarts4rOutput("chartA")
),
tabPanel("Panel B", value = "B", echarts4rOutput("chartB")
)
)
)
server <- function(input, output, session) {
output$chartA <- renderEcharts4r({
data <- data.frame(x = 1:2, y = 1:10)
input$tabsetpanel
e_charts(data, x = x) %>%
e_bar(serie = y)
})
output$chartB <- renderEcharts4r({
data <- data.frame(x = 1:5, y = 11:20)
input$tabsetpanel
e_charts(data, x = x) %>%
e_bar(serie = y)
})
}
shinyApp(ui, server)
Including input$tabsetpanel is very close to what I want, it invalidates the expression. However, for a split second the graph seems to shrink, and only then does it start up again. This looks kinda janky, is there a better approach?