I would like to format number (add big.mark
) in tooltip
in googleVis
chart. Yesterday I asked this quesion: Hover style of label in googleVis and got the answer. Today, I've got quite simillar problem - the difference is that there are more than one group, so adding tooltip
does not work...
The visualisation of my problem:
And my code:
ui.R
:
library("shiny")
library("googleVis")
shinyUI(fluidPage(
htmlOutput("wyk")
))
and server.R
:
library("shiny")
library("googleVis")
library("dplyr")
shinyServer(function(input, output) {
d <- iris %>%
group_by(Species) %>%
summarise(ile=1e6*sum(Sepal.Length),
ile2=1e6*sum(Petal.Length))
output$wyk <- renderGvis({
gvisBarChart(d, xvar = "Species", yvar = c("ile", "ile2"),
options=list(legend="top", bar="{groupWidth:'90%'}", height=500))
})
})
I'd be gratfull for any help!
You can do this using roles, here's an example:
library("shiny")
library("googleVis")
d <- iris %>%
group_by(Species) %>%
summarise(ile=1e6*sum(Sepal.Length),
ile2=1e6*sum(Petal.Length))
d$ile.html.tooltip <- prettyNum(d$ile,big.mark = ",",scientific = F)
d$ile2.html.tooltip <- prettyNum(d$ile2,big.mark = ",",scientific = F)
ggvis_plot <- gvisBarChart(d, xvar = "Species", yvar = c("ile","ile.html.tooltip","ile2","ile2.html.tooltip"),
options=list(legend="top", bar="{groupWidth:'90%'}", height=500))
plot(ggvis_plot)