I have some googleVis charts in a shiny app, but googleVis shorten the label on the horizontal axis by default when they are too long. How do I prevent this behavior? The example below replicates the behavior I would like to prevent:
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)
The link to the documentation is here
That's always a tricky thing, if you ask Google the same question. But I found one 'trick' to show the x-labels, here my workaround:
Change the chart area: the upper "padding" taking space from the hAxis below.
This is possible in R with the options
parameter in the gvisLineChart()
function.
Line <- gvisLineChart(df,
options = list(chartArea =
"{'width': '82%', height: '60%', top: '9%', right: '3%', bottom: '90'}"))
plot(Line)
Of course you have to adjust the values to your needs. Perhaps this approach helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With