Add Hamburg CI colors

This commit is contained in:
2025-12-14 17:11:49 +01:00
parent 5c92cb65da
commit 7dda78712a

View File

@@ -52,7 +52,6 @@ map_data_to_top3_plot <- function(bezirk, stadtteil, year) {
# Beschränken: Wählt die Zeilen 2, 3 und 4 aus.
# Dies sind die Ränge 2, 3 und 4.
slice(2:4)
#top_3_tibble$Name_wrapped <- str_wrap(top_3_tibble$Name, width = 25) #mit wrap ein umbruch bei den namen eingefügt
return(top_3_tibble)
}
@@ -83,7 +82,7 @@ auswahlmöglichkeiten <- crime_json %>%
ui <- function() {
page_fillable(
h1("Kriminalstatistik Hamburg",
style = "color: #006400;",
style = "color: #003063; font-weight: bold;",
class = "ms-4 display-4"),# ms-4 sorgt für den Abstand links
navset_card_tab(
nav_panel("Karte",
@@ -121,7 +120,6 @@ ui <- function() {
),
plotOutput("grph_top3"),
#tableOutput("tbl_2024"),
),
col_widths = c(8, 4),
),
@@ -132,21 +130,59 @@ ui <- function() {
choices = c("Bezirke", "Stadtteile"),
selected = "Bezirke"
),
###selectizeInput ist was wir wollen, wahrscheinlich
selectizeInput(
inputId = "search",
label = "Wählen Sie ein Feld (Schlüssel) aus:",
label = tags$span(icon("search"),"Suche"),
choices = NULL,
selected = NULL,
multiple = FALSE, # Hier wahrscheinlich nur Einzelauswahl gewünscht
options = list(
placeholder = "Start typing..."
placeholder = "Anfangen zu tippen...",
openOnFocus = FALSE,
allowEmptyOption = TRUE,
selectOnTab = FALSE
)
)
),
)
),
nav_panel("Vergleich", "Vergleich_inhalt"),
nav_panel("Vergleich",
layout_sidebar(
sidebar = sidebar(
title = "Vergleichs-Optionen",
radioButtons(
"vergleichs_modus",
"Wählen Sie den Vergleichstyp:",
choices = c(
"Straftat vs. Orte" = "ort_vergleich",
"Ort vs. Straftaten" = "straftat_vergleich"
),
selected = "ort_vergleich"
),
tags$hr(),
# 2. Dynamische Input-Felder für die Orte und Straftaten
uiOutput("vergleichs_inputs"),
# 3. Gemeinsamer Input: Das Jahr
selectizeInput(
"vergleichs_jahr",
"Jahr wählen:",
choices = c(2024, 2023),
selected = 2024
),
),
card(
card_header(uiOutput("vergleichs_titel")), # Dynamischer Titel
plotOutput("vergleichs_plot")
)
)
),
nav_panel("Wiki",
accordion(
accordion_panel(
@@ -203,6 +239,7 @@ server <- function(input, output, session) {
observeEvent(input$rd_maptype, {
maptype <- input$rd_maptype
mapproxy <- leafletProxy("hhmap")
clearGroup(mapproxy, "selected")
if (maptype == "Bezirke"){
hideGroup(mapproxy, "layer_stadtteile")
@@ -224,24 +261,26 @@ server <- function(input, output, session) {
prefix <- get_map_layer_prefix(clicked_polygon_id)
rest_of_name <- get_map_layer_name(clicked_polygon_id)
selected_polygon_data <- NULL
if (prefix == "bez_") {
currently_selected_bezirk(rest_of_name)
currently_selected_stadtteil(paste("Bezirk", rest_of_name))
selected_polygon_data <- geo_bezirke[geo_bezirke[["leaflet_id"]] == click_event$id,]
}
if(prefix == "std_") {
currently_selected_bezirk(get_bezirk_by_stadtteil(rest_of_name))
currently_selected_stadtteil(rest_of_name)
selected_polygon_data <- geo_stadtteile[geo_stadtteile[["leaflet_id"]] == click_event$id,]
}
req(selected_polygon_data)
#neues Polygon über die anderen legen, wenn ein bezirk angeklickt wurde
leafletProxy("hhmap") %>%
clearGroup("selected") %>%
addPolygons(
data = geo_bezirke[geo_bezirke[["leaflet_id"]] == click_event$id, ],
data = selected_polygon_data,
layerId = id,
fillColor = "#51968b",
color = "#7bb5ab",
fillOpacity = 0.1,
color = "#003063",
fillOpacity = 0.2,
weight = 4,
group = "selected"
)
@@ -255,10 +294,11 @@ server <- function(input, output, session) {
data = geo_bezirke,
layerId = ~leaflet_id,
group = "layer_bezirke",
color = "#7bb5ab",
fillOpacity = 0.4, # Polygon fill transparency
color = "#003063",
fillOpacity = 0.2, # Polygon fill transparency
highlightOptions = highlightOptions(
color = "#103b57",
fillOpacity = 0.4,
color = "#003063",
weight = 4,
bringToFront = TRUE
),
@@ -267,13 +307,13 @@ server <- function(input, output, session) {
data = geo_stadtteile,
group = "layer_stadtteile",
layerId = ~leaflet_id,
color = "#7bb5ab",
fillColor = "#bdf0e7",
color = "#003063",
options = pathOptions(pane = "overlayPane"), # Use a leaflet option to ensure it's hidden
weight = 4,
fillOpacity = 0.4, # Polygon fill transparency
weight = 3,
fillOpacity = 0.2, # Polygon fill transparency
highlightOptions = highlightOptions(
color = "#103b57",
fillOpacity = 0.4,
color = "#003063",
weight = 4,
bringToFront = TRUE
),
@@ -299,7 +339,7 @@ server <- function(input, output, session) {
)
req(nrow(data_tibble) > 0)
ggplot(data_tibble, aes(x = Name, y = Erfasst)) +
geom_col(width = 0.7, fill = "#7bb5ab") + # <-- Festlegen der Farbe direkt an allen Spalten angeknüpft nicht mehr anhand der Kategorie
geom_col(width = 0.7, fill = "#e10019") + # <-- Festlegen der Farbe direkt an allen Spalten angeknüpft nicht mehr anhand der Kategorie
geom_text(
# Die Text-Ästhetik soll der Wert aus der Spalte 'Erfasst' sein
aes(label = format(Erfasst, big.mark = ".", decimal.mark = ",")),