2014-11-23 72 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