Increase size of legend

58 views
Skip to first unread message

jlsa...@gmail.com

unread,
Aug 1, 2013, 2:23:59 PM8/1/13
to google-visua...@googlegroups.com
I have a google chart that I am having a problem with the legend. If you look at the chart below, you will note that the descriptions are cropped. I need to expand the size of the left side of the legend. Does anyone know how to do this? Resizing the chart itself does not solve the problem.

You help is appreciated, and my thanks in advance.

My code for the drawing is as follows:
      function drawChart()  {

        // Create the data table.
        var dataHouseholds = new google.visualization.DataTable();
        dataHouseholds.addColumn('string', 'Houshold');
        dataHouseholds.addColumn('number', 'Total');
dataHouseholds.addRows(<?php echo $dataHouseholds; ?>);
        // Set chart options
        var optionsHouseholds = {'title': '<?php echo $TitleHouseholds; ?>',

                       'width':700,
                       'height':400,
                       'backgroundColor.stroke':'#654',
'backgroundColor.strokeWidth':1
};

        // Instantiate and draw chart, passing in some options.

        var chartHouseholds = new google.visualization.BarChart(document.getElementById('chart_Households'));

        chartHouseholds.draw(dataHouseholds, optionsHouseholds);
}

Daniel LaLiberte

unread,
Aug 1, 2013, 2:35:29 PM8/1/13
to google-visua...@googlegroups.com
Hi,

What you want to control is the width of what we call the tick labels for the vertical axis.   The API does not provide a way of setting this width directly, but you can indirectly control it with a combination of the overall width, which you have set to 700, and the chartArea.width.  So for example, you could add this to your options:

    "chartArea": {
      "width": "500"
    }

and that would leave about 200 pixels for the width outside of the chart area.  Keep in mind, this outside area includes the space to the right of the chart as well as the left.  Hope that helps.

dan


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
dlaliberte@Google.com   562D 5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

asgallant

unread,
Aug 1, 2013, 2:52:49 PM8/1/13
to google-visua...@googlegroups.com
You can set chartArea.left to move the starting position of the chartArea as well:

chartArea: {
    width: 500,
    left: 150
}

which should give you more room for the labels.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
dlali...@Google.com   562D 5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA
Message has been deleted

John Salzman

unread,
Aug 1, 2013, 3:15:05 PM8/1/13
to google-visua...@googlegroups.com
Thank you for the replies! This is what worked perfectly.

 'chartArea': {'width': 450,'left': 250},



--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/K0bvoRYcGMs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
thank you,
John Salzman

IT Consultant
Salzman Computing Solutions
Reply all
Reply to author
Forward
0 new messages