Search code examples
rtooltipshinygooglevis

gvisPieChart tooltip - only percentage


In this example, I want a tooltip that shows only the percentage, omitting the absolute value.

a<-c('option1','option2','option3')
b<-c(35,80,10)
data<-data.frame(a,b)

myplot<-gvisPieChart(data,options=list(title='Example',width=1000, height=500))

plot(myplot)

At https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart I found this:

enter image description here

But I do not know how and if it´s possible to adapt to googleVis.

Thanks in advance.

Luis


Solution

  • You can add an option tooltip = "{text:'percentage'}"

    library(googleVis)
    a<-c('option1','option2','option3')
    b<-c(35,80,10)
    data<-data.frame(a,b)
    
    myplot<-gvisPieChart(data,options=list(title='Example',width=1000, height=500
                                           , tooltip = "{text:'percentage'}"))
    
    plot(myplot)
    

    enter image description here