将鼠标悬停在googleVis中的标签样式 [英] Hover style of label in googleVis

查看:90
本文介绍了将鼠标悬停在googleVis中的标签样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在googleVis columnChart中更改悬停标签的样式.我想格式化大数字,因为它是在轴上完成的.您知道如何管理它吗(我已经阅读了整个Internet,但仍然不知道如何修复它:D)?

I'm trying to change the style of hover-label in googleVis columnChart. I'd like to format large numbers as it is done on axis. Do you know how to manage it (I've read whole Internet and still don't know how to fix it :D)?

我的问题的图示(红色是我想要的格式,绿色是我想要的格式):

The illustration of my problem (red is the format I have and green that I'd like to have):

闪亮的应用示例:

ui.R:

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

shinyUI(fluidPage(

    htmlOutput("wyk")

))

和服务器.R:

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

shinyServer(function(input, output) {

    d <- iris %>% group_by(Species) %>% summarise(ile=1e6*sum(Sepal.Length))

    output$wyk <- renderGvis({

      gvisBarChart(d, xvar = "Species", yvar = "ile",
                      options=list(legend="top", bar="{groupWidth:'90%'}", height=500))

    })

})

推荐答案

您可以使用您要显示的文本创建一个额外的列变量,并传递一个y变量向量,并以a.结尾的标签以".tooltip"结尾.工具提示可以使用html标记设置样式. formatbig.mark可以在R中添加逗号.

You can create an extra column variable with the text you want to display and pass a vector of y-variables, giving the label aame ending in ".tooltip". The tooltip can be styled with html tags. format with big.mark can add commas in R.

shinyServer(function(input, output) {

    d <- iris %>% group_by(Species) %>% summarise(ile=1e6*sum(Sepal.Length))
  d$ile.tooltip <- sprintf("<p><b>%s</b><br/><b>%s</b></p>", 
    d$Species, format(d$ile, big.mark=","))

  output$wyk <- renderGvis({
    gvisBarChart(d, xvar = "Species", yvar = c("ile", "ile.tooltip"),
      options=list(legend="top", 
        tooltip="{isHtml:'True'}",  # so you can format it with html
        bar="{groupWidth:'90%'}", height=500))
  })
})

这篇关于将鼠标悬停在googleVis中的标签样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆