简体   繁体   中英

googleVis chart Tooltip: Show percent (via formatter?)

I have created a chart using googleVis in a shiny app but I cannot find a way to set the number in the tooltip as percentage.

I have seen that this is possible if you specify a formatter . How could I possibly implement such a solution for a shiny app?

I know I could customize tooltips via html using roles but I don't want to go down that path.

You can use roles without using html code written by yourself:

    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')
      )
    )

More examples: Using Roles via googleVis

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM