-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotlyGauge.R
58 lines (50 loc) · 1.51 KB
/
plotlyGauge.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
56
57
58
library(plotly)
cases_per_100K_14d = sum(tail(data$new_cases,14))/subset(county_population, STNAME == 'Washington' & CTYNAME == "King County" ,select=POPESTIMATE2019)*100000
fig <- plot_ly(
domain = list(x = c(0, 1), y = c(0, 1)),
value = cases_per_100K_14d[,1],
title = list(text = "Cases per 100k Population"),
type = "indicator",
mode = "gauge+number+delta",
delta = list(reference=52),
gauge = list(
bar = list(
color = "gray"
),
axis = list(
range = c(0,150),
dtick = 10
),
steps = list(
# list(range = c(0,25),color = "lightgreen"),
# list(range = c(25,75), color = "lightyellow"),
# list(range = c(75,100), color = "orange"),
# list(range = c(100,150), color = "red")
list(range = c(0,25),color = "lightgreen"),
list(range = c(25,75), color = "lightyellow"),
list(range = c(75,600), color = "red")
)
))
fig <- fig %>%
layout(margin = list(l=20,r=30))
fig
# fig <- plot_ly(
# domain = list(x = c(0, 1), y = c(0, 1)),
# value = 450,
# title = list(text = "Speed"),
# type = "indicator",
# mode = "gauge+number+delta",
# delta = list(reference = 380),
# gauge = list(
# axis =list(range = list(NULL, 500)),
# steps = list(
# list(range = c(0, 250), color = "lightgray"),
# list(range = c(250, 400), color = "gray")),
# threshold = list(
# line = list(color = "red", width = 4),
# thickness = 0.75,
# value = 490)))
# fig <- fig %>%
# layout(margin = list(l=20,r=30))
#
# fig