Dam*_*mbo 5 r google-visualization googlevis
我在一个闪亮的应用程序中有一些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)
Run Code Online (Sandbox Code Playgroud)
这里是文档的链接
如果你问谷歌同样的问题,这总是一件棘手的事情。但我发现了一个显示 x 标签的“技巧”,这是我的解决方法:
更改图表区域:上方的“填充”占据下方 hAxis 的空间。这在 R 中可以通过函数options中的参数gvisLineChart()实现。
Line <- gvisLineChart(df,
options = list(chartArea =
"{'width': '82%', height: '60%', top: '9%', right: '3%', bottom: '90'}"))
plot(Line)
Run Code Online (Sandbox Code Playgroud)
当然,您必须根据需要调整这些值。也许这个方法对你有帮助。