r - googleVis Treemap drilling up -
are treemaps formed in googlevis
package intended allow "drill-up" functionality?
in example in ?gvistreemap
, treemap forms , allows drill-down functionality in browser. however, mouseover top not appear respond mouse-clicks. can enable drill-up functionality? (i using recent versions of firefox , chrome.)
## please note default googlevis plot command ## open browser window , requires internet ## connection display visualisation. tree <- gvistreemap(regions, idvar="region", parentvar="parent", sizevar="val", colorvar="fac") plot(tree) tree2 <- gvistreemap(regions, "region", "parent", "val", "fac", options=list(width=600, height=500, fontsize=16, mincolor='#edf8fb', midcolor='#66c2a4', maxcolor='#006d2c', headerheight=20, fontcolor='black', showscale=true)) plot(tree2) ## simple static treemap no drill down options based on states ## , area. still have create parent id use ## gvistreemap require(datasets) states <- data.frame(state.name, state.area) ## create parent variable total=data.frame(state.area=sum(states$state.area), state.name="usa") my.states <- rbind(total, states) my.states$parent="usa" ## set parent variable na @ root level my.states$parent[my.states$state.name=="usa"] <- na my.states$state.area.log=log(my.states$state.area) statestree <- gvistreemap(my.states, "state.name", "parent", "state.area", "state.area.log") plot(statestree) ## add regions above data set enable drill down capabilities states2 <- data.frame(state.region, state.name, state.area) regions <- aggregate(list(region.area=states2$state.area), list(region=state.region), sum) my.states2 <- data.frame(regionid=c("usa", as.character(regions$region), as.character(states2$state.name)), parentid=c(na, rep("usa", 4), as.character(states2$state.region)), state.area=c(sum(states2$state.area), regions$region.area, states2$state.area)) my.states2$state.area.log=log(my.states2$state.area) statestree2 <- gvistreemap(my.states2, "regionid", "parentid", "state.area", "state.area.log") plot(statestree2)
to drill-up, needed use right-click.
Comments
Post a Comment