how embed two or more vis charts in one page?

82 views
Skip to first unread message

ARVIND PAWAR

unread,
Apr 20, 2011, 4:16:15 PM4/20/11
to Google Visualization API
i want tow or more corechart in one html page...?
please help me....!

asgallant

unread,
Apr 21, 2011, 8:53:43 AM4/21/11
to Google Visualization API
It's easy...just build your script like this:
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});

function drawCharts(){
var data1 = new google.visualization.DataTable();
var data2 = new google.visualization.DataTable();

<populate data1>
<populate data2>

var chart1 = new google.visualization.<chart 1
type>(document.getElementById('chart_1_div'));
var chart2 = new google.visualization.<chart 2
type>(document.getElementById('chart_2_div'));

var options1 = {<options>};
var options2 = {<options>};

chart1.draw(data1, options1);
chart2.draw(data2, options1);
}

google.setOnLoadCallback(drawCharts);
</script>

and you will have two charts.

PavolK

unread,
May 31, 2015, 7:13:59 PM5/31/15
to google-visua...@googlegroups.com, arvin...@gmail.com
Can anyone please use specific examples of the lines below for complete beginners like me?  Thanks a lot! 
<populate data1> 
<populate data2> 

and

Jack Scotson

unread,
Jun 2, 2015, 8:47:44 AM6/2/15
to google-visua...@googlegroups.com, arvin...@gmail.com
<populate data1>
This would be where you populate the data table, using:
data1.addColumn('columnType','columnName');
data1
.addColumn('columnType','columnName');
data1
.addRows([["Test",1], ["Test2",2]]);
This will add the data. To add the data for the second table, simply replace 'data1.' for 'data2.'
For options, this would be where you set your options specific to your type of table.
For example:
      var options1 = {
        title
: "Density of Precious Metals, in g/cm^3",
        width
: 600,
        height
: 400,
        bar
: {groupWidth: "95%"},
        legend
: { position: "none" },
     
};

And again, the same applies with this, replace 'options1' with 'options2'
Reply all
Reply to author
Forward
0 new messages