2014-11-23 68 views
1

我已經在閃亮的應用程序中使用googleVis創建了圖表,但我無法找到以百分比形式在工具提示中設置數字的方法。googleVis圖表工具提示:顯示百分比(通過格式化程序?)

我已經看到,如果您指定formatter,這是可能的。我怎麼可能實現這樣一個閃亮的應用程序的解決方案?

我知道我可以通過使用角色的html自定義工具提示,但我不想沿着這條路徑走下去。

+0

我剛纔已經回答了類似的問題在這裏... https://stackoverflow.com/questions/ 6724451/how-to-set-tooltips-to-display-percentage-to-match-axis-in-google-visualization/48874196#48874196 Cheers – 2018-02-19 21:20:01

+0

我剛剛在這裏回答了一個類似的問題... https://stackoverflow.com/questions/6724451/how-to-set-tooltips-to-display-percentageages-to-match-axis-in-google-visualization/48874196#48874196 Cheers – 2018-02-19 21:21:44

回答

1

您可以使用角色,不使用自己編寫的html代碼:

library(googleVis) 
    dat <- data.frame(Year=2010:2013, 
         Sales=c(600, 1500, 800, 1000), 
         Sales.html.tooltip=c('15.4%', 
              '38.4%', 
              '20.5%', 
              '25.7%'), 
         Sales.certainty=c(TRUE, FALSE, TRUE, FALSE)) 
    plot(
     gvisColumnChart(dat, xvar='Year', 
         yvar=c('Sales', 'Sales.certainty', 'Sales.html.tooltip') 
    ) 
    ) 

更多的例子:Using Roles via googleVis