2014-02-06 43 views
1

googleVis包中形成的樹形圖旨在允許「鑽取」功能嗎?googleVis樹形圖鑽取

?gvisTreeMap的示例中,樹形圖很好地形成並允許在瀏覽器中展開下鑽功能。但是,頂部的鼠標懸停似乎無法響應鼠標點擊。我能做些什麼來啓用鑽取功能? (我使用的是最新的Firefox和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) 

回答

0

要向上追溯,我只需要使用鼠標右鍵點擊。

0

我今天也遇到了這個問題,並發現右鍵點擊成爲答案。有關此示例中使用的代碼的更完整示例,可以在前面提到的?gvisTreeMaprDocumentation.org中找到。我在試圖理解gvisTrepMap時遇到了這個問題,但發現鏈接的文檔給了我更全面的函數描述。

0

我發現控制 - 左鍵單擊也縮小。在我的Mac OS/X上,在Chrome,Firefox和內置的R-Studio查看器中。