Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent googleVis from shortening labels?

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

like image 275
Dambo Avatar asked Oct 19 '22 00:10

Dambo


1 Answers

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.

like image 125
J_F Avatar answered Oct 31 '22 19:10

J_F