-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
51 lines (44 loc) · 1.58 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
library(shiny)
library(sf)
library(ggplot2)
# library(plotly)
library(ggiraph)
ui <- fluidPage(
titlePanel("Cose"),
sidebarLayout(
sidebarPanel(
selectInput("level",
"Livello geografico:",
choices = c("provincia", "regione"),
selected = "regione")
),
mainPanel(
girafeOutput("mapIta")
)
)
)
server <- function(input, output) {
output$mapIta <- renderGirafe({
if (input$level == "regione") {
ita_shape <- st_read("data/basi_geo/Limiti_1991_ED50_g/Reg1991_ED50 _g/Reg1991_ED50_g.shp")
colnames(ita_shape)[colnames(ita_shape) == "REGIONE"] <- "name"
} else if (input$level == "provincia") {
ita_shape <- st_read("data/basi_geo/Limiti_1991_ED50_g/Prov1991_ED50_g/Prov1991_ED50_g.shp")
colnames(ita_shape)[colnames(ita_shape) == "PROVINCIA"] <- "name"
}
ita_shape$name <- gsub("'", "'", ita_shape$name)
p <- ggplot(ita_shape) +
geom_sf_interactive(aes(geometry = geometry,
tooltip = name,
data_id = name),
hover_nearest = TRUE) +
theme_void()
girafe(ggobj = p)
# p <- ggplotly(p, tooltip = "text")
# style(p, hoveron = "fill")
# style(p, hoverinfo = "text", hoveron = "fill")
# style(p, text = p$x$data[[1]]$, hoveron = "fill")
})
}
# Run the application
shinyApp(ui = ui, server = server)