By Amit
So Key Performance Indicators (KPIs) are all the rage in the dashboarding community… well everywhere really. The premise is simple… check a list of measurements against targets and show how they compare using some kind of visualization. I haven’t yet seen, however, a version that can utilize animated icons to display indicators that REALLY need attention. So here you go, a tutorial on how to make your very own animated icon KPI, using the googleVis library.
Suppose we have a dataset that looks like this (make sure to set your working directory):
library(googleVis)
## Set wd
setwd("your folder")
df measure=round(runif(15,max=10),2),
target=round(runif(15,max=10),2))
## unimpresive dashboard
plot(gvisTable(df))
A normal KPI would then compare the measure to the target and apply some rationale. Suppose in our case that green indicates that for that indicator you are within 80% of your target. Yellow means up to 50% of target, and red is below that.
Now, we need some icons. We can download them, or make them ourselves (protip: MS Powerpoint has some interesting possibilities with their glow/highlight/dropshadow options so this might be a good place to start if you’re not a graphic designer). Now that we have icons, we can split up the dataset into good, bad and medium categories and assign icons to each:
## Make more interesting one... first set target thresholds
Threshold1 Threshold2 ## high trigger
df$graphic[df$measure/df$target > Threshold1] ''
## low trigger
df$graphic[df$measure/df$target ''
## medium trigger
df$graphic[is.na(df$graphic)] ''
plot(gvisTable(df))
Oh no! Why won’t it work? Relax, it’s because we are in the localhost. See how the address is http://127.0.0.1/… ? This isn’t a real webpage, it’s launching from your computer. We need to port out the right elements into a handy-dandy webpage (the code is very ugly, but SUPER flexible… you can pass css elements, titles, javascript… hell you can even create a fully functional webpage like this! I love this method, …read more
Source:: r-bloggers.com