Chart Legend position

17,079 views
Skip to first unread message

davidcsi

unread,
Feb 3, 2012, 1:00:02 PM2/3/12
to Google Visualization API
Hello guys,

I want to set "chdlp=bv" but i don't know where!

My chart works like this:


<html>
<head>
<script type="text/javascript" src="https://www.google.com/
jsapi"></script>
</head>
<body>
<table>
<tr>

<script type='text/javascript'>
google.load('visualization', '1', {packages:['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Date-Time');
data.addColumn('number', 'Value1');
data.addColumn('number', 'Value2');
data.addRows([
['31-00',15131,13660],
['02-00',18059,16659],
['01-00',16478,15551],
['03-15',58972,57581],
['29-00',22099,21259],
['30-00',15679,14819],
['03-16',61501,59771],
['03-17',63691,62066]
]);
var options = {
width: 800, height: 600,
title: 'HLR Performance',
legend : 'top'
};

var chart = new
google.visualization.LineChart(document.getElementById('chart_div_1'));
chart.draw(data, options);
}
</script>
</tr>
</table>
</body>
</html>

asgallant

unread,
Feb 3, 2012, 2:50:06 PM2/3/12
to google-visua...@googlegroups.com
If I have it correctly, 'chdlp=bv' puts the chart legend in a vertical list at the bottom of the chart in the Image Charts API.  If so, you can't quite do that with the Visualization API charts.  Setting the legend.position option to 'top' or 'bottom' creates a horizontal legend, while setting it to 'right' creates a vertical legend.

You are also using the legend option incorrectly; it should be:

var options = {
          width: 800, height: 600,
          title: 'HLR Performance',
          legend: {
                    position: 'top'
          }
};

davidcsi

unread,
Feb 7, 2012, 12:40:15 PM2/7/12
to Google Visualization API
Hello,

Sorry, I hadn't seen the reply.

What I mean to ask is who to use those options? I don't know how, I
use opitons like:

var options = {
width: 800, height: 600,
title: 'HLR Performance',
legend: {
position: 'top'
}

But you can not use "chdlp" like that... or can you?

Thanks

David

asgallant

unread,
Feb 7, 2012, 12:56:27 PM2/7/12
to google-visua...@googlegroups.com
Options like 'chdlp' are for the Image Charts; they don't work for the Visualization API Charts.  If you want to use the Image Charts, you can see how they work here: http://code.google.com/apis/chart/image/
Reply all
Reply to author
Forward
0 new messages