Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minichart non-reactive (time) #51

Open
antoine4ucsd opened this issue May 3, 2023 · 0 comments
Open

minichart non-reactive (time) #51

antoine4ucsd opened this issue May 3, 2023 · 0 comments

Comments

@antoine4ucsd
Copy link

Hi
great package!
I followed your tutorials:
https://cran.r-project.org/web/packages/leaflet.minicharts/vignettes/introduction.html
and here
https://francoisguillem.shinyapps.io/shiny-demo/

with my data, it works just fine with this code:

leaf_map2 %>%
        addMinicharts(
                coordinates_list_all$Longitude, coordinates_list_all$Latitude,
                type = "pie",
                chartdata = coordinates_list_all[, c("VOC50", "VOC90")],
                # colorPalette = colors,
                width = 60 * sqrt(coordinates_list_all$total_cases) / sqrt(max(coordinates_list_all$total_cases)), 
                time = coordinates_list_all$date,
        )
 

but when I try to use within shiny app, the minichart are not updating (the panel looks fine)

 
server = function(input, output, session) {
        # Initialize map
        #
        
        output$map <- renderLeaflet({
                leaf_map2%>% leaflet::addTiles(tilesURL)%>%
                        addMinicharts(
                                coordinates_list_all$Longitude, coordinates_list_all$Latitude,
                                layerId = coordinates_list_all$location,
                                width = 45, height = 45,
                        )
        })
       
        # Update charts each time input value changes
        observe({
                if (length(input$prods) == 0) {
                        data <- 1
                } else {
                        data <- coordinates_list_all[, input$prods]
                }
                maxValue <- max(as.matrix(data))
               
                leafletProxy("map", session) %>%
                        updateMinicharts(
                                coordinates_list_all$location,
                                chartdata = data,
                                maxValues = maxValue,
                                time = coordinates_list_all$date,
                                type = ifelse(length(input$prods) < 2, "polar-area", input$type),
                                showLabels = input$labels
                        )
        })
}
 
ui <- fluidPage(
        titlePanel("COVID-19 Clinical data"),
        p("This application uses the data xxxx COVID-19.",
          "It contains the quarterly data on total cases, VOC 50%, VOC 75% and  VOC 90% from 2020 to 2023."),
       
        sidebarLayout(
               
                sidebarPanel(
                        selectInput("prods", "Select data", choices = dataCols, multiple = TRUE),
                        selectInput("type", "Chart type", choices = c("bar","pie", "polar-area", "polar-radius")),
                        checkboxInput("labels", "Show values")
                ),
               
                mainPanel(
                        leafletOutput("map")
                )
               
        )
)
shinyApp(ui, server)

my data look like that (for now I included same value for the different VOC but won’t be the case after) with prods being total_cases, VOC50, VOC75 and VOC90. the problem seems to be around the time component (nothing change when I click on 'play')

did I miss something here?

Screen Shot 2023-05-03 at 8 16 02 AM

thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant