-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_server.R
55 lines (51 loc) · 1.21 KB
/
app_server.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
52
53
54
55
server <- function(input, output) {
# Vis 1 - Line
output$line <- renderPlotly({
# Select data widget
line_data <- get(input$line_select)
# Plot
line.plot <- plot_ly(line_data,
x = line_data$order_date,
y = line_data$cumulative,
type = "scatter",
mode = "lines",
line = list(color = "#89ce61")
) %>%
layout(
title = input$line_select,
xaxis = list(
rangeslider = list(type = "date"),
title = "Date"
),
yaxis = list(title = "")
)
return(ggplotly(line.plot))
})
# Vis 2 - Map
output$map <- renderPlotly({
# Select data widget
map_data <- get(input$map_select)
map_shape <- get(input$map_shape_select)
# Plot
map.plot <- ggplot() +
geom_polygon(
data = map_shape,
aes(x = long, y = lat, group = group),
alpha = 0.3,
fill = "#89ce61"
) +
geom_point(
data = map_data,
aes(
x = lon,
y = lat,
alpha = total,
text = paste("farm:", farm_name)
),
color = "dark green"
) +
theme_void() +
coord_map() +
ggtitle(paste(input$map_select, "since 2019"))
})
}