-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdashboard maker.R
61 lines (48 loc) · 1.48 KB
/
dashboard maker.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
59
60
61
library(googleVis)
## Set wd
setwd("your folder")
df <- data.frame(thing=paste("Item",1:15),
measure=round(runif(15,max=10),2),
target=round(runif(15,max=10),2))
## unimpresive dashboard
plot(gvisTable(df))
## Make more interesting one... first set target thresholds
Threshold1 <- 0.8
Threshold2 <- 0.5
## Now do measure/target and compare against Thresholds
## high trigger
df$graphic[df$measure/df$target > Threshold1] <-
'<img src="green.gif">'
## low trigger
df$graphic[df$measure/df$target < Threshold2] <-
'<img src="red.gif">'
## medium trigger
df$graphic[is.na(df$graphic)] <-
'<img src="yellow.gif">'
plot(gvisTable(df))
## won't work on local... push to an html file and all will be good.
##--- Make html ----
ObsRep <- gvisTable(df)
# plot(ObsRep)
cat(paste("<html><head></head><body>",
"<h1>Best Dashborde!!!1!</h1>",sep=""),
ObsRep$html$header,
ObsRep$html$chart,
"</body></html>",
file="AnimatedKPIdashboard.html")
browseURL("AnimatedKPIdashboard.html")
## Decent, but add one last trigger:
Threshold3 <- 0.2
## lowlowlowlowlow trigger
df$graphic[df$measure/df$target < Threshold3] <-
'<img src="redFlashing.gif">'
##--- Make html again ----
ObsRep <- gvisTable(df)
# plot(ObsRep)
cat(paste("<html><head></head><body>",
"<h1>Best Dashborde!!!1!</h1>",sep=""),
ObsRep$html$header,
ObsRep$html$chart,
"</body></html>",
file="AnimatedKPIdashboard.html")
browseURL("AnimatedKPIdashboard.html")