Question

Are treemaps formed in the googleVis package intended to allow "drill-up" functionality?

In the example in ?gvisTreeMap, the treemap forms well and allows for drill-down functionality in my browser. However, the mouseover for the top does not appear to respond to mouse-clicks. What can I do to enable drill-up functionality? (I am using the most recent versions of Firefox and Chrome.)

## Please note that by default the googleVis plot command
## will open a browser window and requires Internet
## connection to display the 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 with no drill down options based on US states
## and their area. However we still have to create a parent id to 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 to NA at 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)


## We add US regions to the above data set to 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)
Was it helpful?

Solution

To drill-up, I just needed to use right-click.

OTHER TIPS

I ran into this issue today as well and found right click to be the answer. For a fuller example of the code used in this example it can be found in the earlier mentioned ?gvisTreeMap or from rDocumentation.org. I landed on this question in trying to understand gvisTrepMap but found the linked documentation to give me a much fuller description of the function.

I find that control-left-click also zooms-out. On my Mac OS/X, in Chrome, Firefox and the built-in R-Studio viewer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top