【问题标题】:How do I prevent googleVis from shortening labels?如何防止 googleVis 缩短标签?
【发布时间】:2016-10-03 03:15:18
【问题描述】:

我在一个闪亮的应用程序中有一些 googleVis 图表,但是当它们太长时,googleVis 默认会缩短横轴上的标签。如何防止这种行为?下面的示例复制了我想要阻止的行为:

df=data.frame(country=c(paste(rep("very very long label", 1e+2)), "GB", "BR"), 
              val1=c(10,13,14), 
              val2=c(23,12,32))
Line <- gvisLineChart(df)
plot(Line)

文档的链接是here

【问题讨论】:

  • 整体heightchartArea.height 都有configuration options -- 建议同时设置,减少chartArea.height 直到完全显示 -- 还要检查hAxis.slantedTexthAxis.slantedTextAngle。 ..

标签: r google-visualization googlevis


【解决方案1】:

如果您向 Google 提出同样的问题,这总是一件棘手的事情。但是我发现了一个显示 x-labels 的“技巧”,这是我的解决方法:

更改图表区域:上方的“填充”从下方的 hAxis 中占据空间。 这在 R 中可以通过 gvisLineChart() 函数中的 options 参数实现。

Line <- gvisLineChart(df,
    options = list(chartArea = 
 "{'width': '82%', height: '60%', top: '9%', right: '3%', bottom: '90'}"))

plot(Line)

当然,您必须根据需要调整值。也许这种方法对您有帮助。

【讨论】:

  • 我正在尝试按照您的建议调整我的图表,但我无法弄清楚为什么更改 height 不会影响图表的区域(即显示条形的平面)。有什么建议吗?
猜你喜欢
  • 1970-01-01
  • 2014-06-07
  • 2013-01-15
  • 2021-10-23
  • 2017-05-07
  • 1970-01-01
  • 2015-10-04
  • 2010-09-12
  • 1970-01-01
相关资源
最近更新 更多