1

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.

Community
  • 1
  • 1
Christos
  • 805
  • 8
  • 25
  • I just answered a similar question here... https://stackoverflow.com/questions/6724451/how-to-set-tooltips-to-display-percentages-to-match-axis-in-google-visualization/48874196#48874196 Cheers – DanimalReks Feb 19 '18 at 21:20
  • I just answered a similar question here... https://stackoverflow.com/questions/6724451/how-to-set-tooltips-to-display-percentages-to-match-axis-in-google-visualization/48874196#48874196 Cheers – DanimalReks Feb 19 '18 at 21:21

1 Answers1

1

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

Mikael Jumppanen
  • 2,436
  • 1
  • 17
  • 29