Add first R dashboard draft
This commit is contained in:
60
IT Shiny App.R
Normal file
60
IT Shiny App.R
Normal file
@@ -0,0 +1,60 @@
|
||||
library(rjson)
|
||||
library(shiny)
|
||||
library(bslib)
|
||||
library(leaflet)
|
||||
|
||||
|
||||
crime_json <- fromJSON(file="C:\\Users\\milli\\Documents\\Datenbereinigung\\data.json")
|
||||
bezirke <- names(crime_json)
|
||||
|
||||
ui <- page_fillable(
|
||||
layout_columns(
|
||||
card(
|
||||
selectInput(
|
||||
inputId = "drp_bezirk",
|
||||
label = "Bezirk",
|
||||
choices = bezirke),
|
||||
selectInput(
|
||||
inputId = "drp_stadtteil",
|
||||
label = "Stadtteil",
|
||||
choices = NULL,
|
||||
)
|
||||
),
|
||||
leafletOutput("hhmap"),
|
||||
card("Card rechts"),
|
||||
col_widths = c(3, 6, 3)
|
||||
)
|
||||
)
|
||||
server <- function(input, output, session){
|
||||
|
||||
observeEvent(input$drp_bezirk, {
|
||||
sel_bezirk <- input$drp_bezirk
|
||||
|
||||
if (sel_bezirk != "") {
|
||||
|
||||
# Neue Auswahlmöglichkeiten bestimmen
|
||||
sel_stadtteile <- names(crime_json[[sel_bezirk]])
|
||||
|
||||
# Zweites SelectInput-Feld aktualisieren
|
||||
updateSelectInput(
|
||||
session,
|
||||
inputId = "drp_stadtteil",
|
||||
choices = sel_stadtteile,
|
||||
selected = sel_stadtteile[1] # Wählt den ersten Eintrag vor
|
||||
)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
output$hhmap <- renderLeaflet({
|
||||
leaflet() %>%
|
||||
addProviderTiles(providers$CartoDB.Positron) %>%
|
||||
setView(
|
||||
lng = 9.98716634776887,
|
||||
lat = 53.5488439196432,
|
||||
zoom = 10
|
||||
)
|
||||
})
|
||||
}
|
||||
shinyApp(ui = ui, server = server)
|
||||
|
||||
Reference in New Issue
Block a user