diff --git a/server.R b/server.R index 6cdbecd..a6a3bff 100644 --- a/server.R +++ b/server.R @@ -14,6 +14,10 @@ server <- function(input, output, session) { currently_selected_maptype <- reactiveVal("Bezirke") currently_selected_heatmap_crime <- reactiveVal("Allgemeine Verstöße gem. § 29 BtMG -Konsumentendelikte-") + + currently_compared_location <- reactiveVal(c("")) + currently_compared_crimes <- reactiveVal(c("")) + # 1. Aktualisieren der Auswahlmöglichkeiten mit den extrahierten Schlüsselnamen updateSelectizeInput( session = session, @@ -242,12 +246,22 @@ server <- function(input, output, session) { }, res = 100) - output$tbl_2024 <- renderTable( - map_data_to_table( - bezirk = currently_selected_bezirk(), - stadtteil = currently_selected_stadtteil(), + observeEvent(input$vergleich_location, { + currently_compared_location(c(input$vergleich_location)) + }) + observeEvent(input$vergleich_straftat, { + currently_compared_crimes(input$vergleich_straftat) + }) + + output$vergleich_balkendiagramm <- renderPlot({ + data_tibble <- map_data_to_plot( + locations = currently_compared_location(), + crimes = currently_compared_crimes(), year = "2024" - ), - striped = TRUE - ) + ) + + ggplot(data_tibble, aes(x = Location, y = Erfasst, group = Name, fill = Name)) + + geom_col(position = position_dodge(width = 0.9)) + }, res = 100) + } \ No newline at end of file