Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent legend labels being cut off in Google charts

Tags:

With a Perl script I generate numerous Google Line Charts for 20 and more series of data at once.

The legend labels are of the form: a serial number appended by an iterating #counter.

Unfortunately, starting with #10 those counters are cut off:

enter image description here

Is there maybe a way to stop Google charts from doing that?

My quite simple chart code is below:

    var data = { ...... };      function drawCharts() {             for (var csv in data) {                     var x = new google.visualization.DataTable(data[csv]);                      var options = {                             title: csv,                             width: 800,                             height: 600                     };                      var chart = new google.visualization.LineChart(document.getElementById(csv));                     chart.draw(x, options);             }     }      $(function() {             google.setOnLoadCallback(drawCharts);     }); 
like image 990
Alexander Farber Avatar asked Jun 07 '13 08:06

Alexander Farber


People also ask

How do I hide the legend in my Google chart?

To hide the legend in Google Chart with JavaScript, we set the legend property to 'none' . const options = { //... legend: "none", }; to set legend to 'none' in the options object to hide the legend.

How do I remove the legend from a pie chart in Google Sheets?

The Legend is hidden by setting the legend property to none in the Google Chart Options. title: 'USA City Distribution', legend: 'none' // Hides the Legend.


1 Answers

To get full legend in your chart just add chartArea width and height as below

var options = {               title: csv,               width: 800,               height: 600,               chartArea: {  width: "50%", height: "70%" } }; 

Take a look at this jqfaq.com to get a working sample

like image 190
Swarna Latha Avatar answered Sep 19 '22 13:09

Swarna Latha