Created
February 2, 2016 20:39
-
-
Save DataStrategist/dedb96ce2cebd8b6f6bc to your computer and use it in GitHub Desktop.
A demonstration on how to make a KPI Dashboard that displays animated gifs depending on results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googleVis) | |
## Set wd | |
setwd("your folder") | |
df <- data.frame(thing=c("A","B","C","D"), | |
measure=c(12,3,4.5,17)) | |
## unimpresive dashboard | |
plot(gvisTable(df)) | |
## Make more impressive one... first set targets | |
Target1 <- 4 | |
Target2 <- 10 | |
Link1 <- 'https://cdn2.scratch.mit.edu/get_image/gallery/1434108_200x130.png' | |
Link2 <- 'https://media.giphy.com/media/Vmunw0k7q12Ks/giphy.gif' | |
## Low trigger | |
df$graphic[df$measure < Target1] <- | |
paste('<img src="', Link1, '" width="50px">', sep="") | |
## High trigger | |
df$graphic[df$measure > Target2] <- | |
paste('<img src="', Link2,'" width="50px">', sep="") | |
# df <- df[,c(1,3)] | |
##--- 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") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment