Hi,

If you fix your setValue calls to set column number 1 instead of column
number 2, and the closing script tag at the beginning, everything seems to
work just fine.

Here's the fixed code:
------------------------------
<script type="text/javascript" src="http://www.google.com/jsapi";></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["linechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
       var data1= new google.visualization.DataTable();
       data1.addColumn('string', 'Date');
       data1.addColumn('number', 'Test1');
       data1.addRows(30);
       data1.setValue(0, 0, 'test1');
       data1.setValue(0, 1, 1);
       data1.setValue(1, 0, 'test2');
       data1.setValue(1, 1, 2);

       var chart1 = new google.visualization.LineChart
(document.getElementById('div_1'));
       chart1.draw(data1, {width: 600, height: 340, legend: 'bottom',
title: 'Chart 1'});

var data2= new google.visualization.DataTable();
       data2.addColumn('string', 'Date');
       data2.addColumn('number', 'Active Members');
       data2.addRows(30);
       data2.setValue(0, 0, 'test1');
       data2.setValue(0, 1, 1);
       data2.setValue(1, 0, 'test2');
       data2.setValue(1, 1, 2);

       var chart2 = new google.visualization.LineChart
(document.getElementById('div_2'));
       chart2.draw(data2, {width: 600, height: 340, legend: 'bottom',
title: 'Chart 2'});

}
</script>


   <div id="div_1"></div>

<br />

   <div id="div_2"></div>

--------------------


Regards,
    VizBoy.

On Wed, Jan 7, 2009 at 2:50 PM, John <[email protected]> wrote:

>
> I want to show more than one chart on a page.
> This is what I have so far:
>
> <script type="text/javascript" src="http://www.google.com/jsapi";></
> script>
> <script type="text/javascript">
> google.load("visualization", "1", {packages:["linechart"]});
> google.setOnLoadCallback(drawChart);
> function drawChart() {
>        var data1= new google.visualization.DataTable();
>        data1.addColumn('string', 'Date');
>        data1.addColumn('number', 'Test1');
>        data1.addRows(30);
>        data1.setValue(0, 0, 'test1');
>        data1.setValue(0, 2, 1);
>        data1.setValue(1, 0, 'test2');
>        data1.setValue(1, 2, 2);
>
>        var chart1 = new google.visualization.LineChart
> (document.getElementById('div_1'));
>        chart1.draw(data1, {width: 600, height: 340, legend: 'bottom',
> title: 'Chart 1'});
>
> var data2= new google.visualization.DataTable();
>        data2.addColumn('string', 'Date');
>        data2.addColumn('number', 'Active Members');
>        data2.addRows(30);
>        data2.setValue(0, 0, 'test1');
>        data2.setValue(0, 2, 1);
>        data2.setValue(1, 0, 'test2');
>        data2.setValue(1, 2, 2);
>
>        var chart2 = new google.visualization.LineChart
> (document.getElementById('div_2'));
>        chart2.draw(data2, {width: 600, height: 340, legend: 'bottom',
> title: 'Chart 2'});
>
> }
> </script>
>
>
>    <div id="div_1"></div>
>
> <br />
>
>    <div id="div_2"></div>
>
>
> Only the first chart is shown on the page!
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to