我想格式化big.mark图表中tooltip中的数字(添加googleVis)。昨天我问了以下问题:Hover style of label in googleVis并得到了答案。今天,我遇到了一个非常相似的问题-区别在于存在多个组,因此添加tooltip不起作用...

我的问题的可视化:
javascript - googleVis中的格式工具提示-LMLPHP

而我的代码:

ui.R

library("shiny")
library("googleVis")

shinyUI(fluidPage(

    htmlOutput("wyk")

))


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


如果有任何帮助,我将不胜感激!

最佳答案

您可以使用roles进行此操作,这是一个示例:

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)

关于javascript - googleVis中的格式工具提示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36150184/

10-12 13:56