Multiple pie charts on one page

1,881 views
Skip to first unread message

akm

unread,
May 30, 2012, 2:09:34 PM5/30/12
to google-visua...@googlegroups.com
How can I create multiple pie charts on one page?  I've tried using different divs, using different function names, but still just the second chart shows up.

asgallant

unread,
May 30, 2012, 2:48:27 PM5/30/12
to google-visua...@googlegroups.com
Each pie chart needs its own div on the page.  You can either draw them all in one function (good if they share a common DataTable) or draw them in separate functions.  If you draw in separate functions, then it is a good idea to create one initializing function that calls the drawing functions, and use that as the callback, like this:

google.load('visualization''1'{packages:['corechart']});
google.setOnLoadCallback(drawCharts);

function drawCharts ({
    drawPie1();
    drawPie2();
    drawPie3();
}

function drawPie1 ({
    // draw the first pie chart
}

function drawPie2 ({
    // draw the second pie chart
}

function drawPie3 ({
    // draw the third pie chart
Reply all
Reply to author
Forward
0 new messages