Use plotly for better graphs

This commit is contained in:
2026-02-05 16:23:45 +01:00
parent d31650131b
commit dc790f554d
3 changed files with 12 additions and 10 deletions

View File

@@ -216,14 +216,14 @@ server <- function(input, output, session) {
)
})
output$grph_top3 <- renderPlot({
output$grph_top3 <- renderPlotly({
data_tibble <- map_data_to_top3_plot(
bezirk = currently_selected_bezirk(),
stadtteil = currently_selected_stadtteil(),
year = "2024"
)
req(nrow(data_tibble) > 0)
ggplot(data_tibble, aes(x = reorder(Name, -Erfasst), y = Erfasst, fill = Name)) +
ggplotly(ggplot(data_tibble, aes(x = reorder(Name, -Erfasst), y = Erfasst, fill = Name)) +
geom_col(width = 0.7) +
scale_x_discrete(
labels = function(x) str_wrap(x, width = 15)) +
@@ -279,8 +279,8 @@ server <- function(input, output, session) {
margin = margin(r = 15) # r = right (rechts) in Pixeln
),
)
}, res = 100)
)
})
observeEvent(input$vergleich_location, {
currently_compared_location(c(input$vergleich_location))
@@ -289,14 +289,14 @@ server <- function(input, output, session) {
currently_compared_crimes(input$vergleich_straftat)
})
output$vergleich_balkendiagramm <- renderPlot({
output$vergleich_balkendiagramm <- renderPlotly({
data_tibble <- map_data_to_plot(
locations = currently_compared_location(),
crimes = currently_compared_crimes(),
year = currently_compared_year()
)
ggplot(data_tibble, aes(x = Erfasst, y = reorder(Location, Erfasst, FUN = sum), group = Name, fill = Name)) + #reorder macht die höchsten Werte nach oben, und sortiert nach Gesamtwert
ggplotly(ggplot(data_tibble, aes(x = Erfasst, y = reorder(Location, Erfasst, FUN = sum), group = Name, fill = Name)) + #reorder macht die höchsten Werte nach oben, und sortiert nach Gesamtwert
geom_col(position = position_dodge(width = 0.9)) +
scale_fill_brewer(palette = "Blues") +
geom_text(
@@ -352,7 +352,8 @@ server <- function(input, output, session) {
# Fügen Sie hier einen Abstand nach RECHTS hinzu
margin = margin(r = 15) # r = right (rechts) in Pixeln
)
)
}, res = 100)
)
)
})
}