googleVis chart Tooltip: Show percent (via formatter?)

369 views Asked by At

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.

1

There are 1 answers

0
Mikael Jumppanen On BEST ANSWER

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