5

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

Dambo
  • 3,318
  • 5
  • 30
  • 79
  • there are [configuration options](https://developers.google.com/chart/interactive/docs/gallery/columnchart#configuration-options) for both overall `height` and `chartArea.height` -- recommend setting both, reducing `chartArea.height` until fully displayed -- also check `hAxis.slantedText` & `hAxis.slantedTextAngle` as well... – WhiteHat Oct 05 '16 at 22:58

1 Answers1

3

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.

J_F
  • 9,956
  • 2
  • 31
  • 55
  • I am trying to tweak my charts following your suggestion but I cannot figure out why changing `height` does not affect the area of the charts (meaning the plane where the bars are displayed). Any suggestions? – Dambo Oct 05 '16 at 19:48