How to put two charts at different place in a page

14 views
Skip to first unread message

dib258

unread,
Jul 7, 2011, 9:25:46 AM7/7/11
to Google Visualization API
Hi,

I'm using the google API to create a Column chart. I read the
documentation but now i have a little problem.
Cause i need to put two charts on the same page at different places.
So i don't know how to implement the code.

My actual code looks like a basic chart but i don't know if i need to
copy all the code, or if i need to create a second function
drawChart() and also wich div's id do i have to put.

Thanks in advance for your answer

Have a nice day

asgallant

unread,
Jul 8, 2011, 8:56:37 AM7/8/11
to google-visua...@googlegroups.com
You can draw two charts within a single function:

function drawCharts() {
var data1 = new google.visualization.DataTable();
<populate data1>

var data2 = new google.visualization.DataTable();
<populate data2>

var chart1 = new google.visualization.ColumnChart(document.getElementById("chart_div_1"));
chart1.draw(data1, <options>);

var chart2 = new google.visualization.ColumnChart(document.getElementById("chart_div_2"));
chart2.draw(data2, <options>);
}

The div ID's are arbitrary; use whatever you choose to name them in the HTML.
Reply all
Reply to author
Forward
0 new messages