Solved

Google multiple charts not showing... only one shows up

Posted on 2012-04-06
9
486 Views
Last Modified: 2012-06-22
I have two scripts to load the image charts (radar) but only one shows up.

Any advice?

-hellenica

 <table>
      <tr>
      <td width="300">
        
        
         <div id="chart1"></div>
         <div id="chart2"></div>

   <script type="text/javascript">
      var queryString = '';
      var dataUrl = '';

      function onLoadCallback() {
        if (dataUrl.length > 0) {
          var query = new google.visualization.Query(dataUrl);
          query.setQuery(queryString);
          query.send(handleQueryResponse);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_congress['issueGreece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_congress['issuePatriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_congress['issueViolations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_congress['issueFyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_congress['issueCaucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart1'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '-5,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: 'Congressional Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback);

    </script>         
    </td>
        
    <td width="300">
     
     
     <script type="text/javascript">
      var queryString = '';
      var dataUrl = '';

      function onLoadCallback() {
        if (dataUrl.length > 0) {
          var query = new google.visualization.Query(dataUrl);
          query.setQuery(queryString);
          query.send(handleQueryResponse);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_statsState['cyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_statsState['greece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_statsState['patriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_statsState['violations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_statsState['fyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_statsState['caucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_statsState['cyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart2'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '-5,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: '<?php echo $row_rs_congress['STATE']; ?> Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback);

    </script>                 
            </td>
            </tr></table>

Open in new window

0
Comment
Question by:marcoullis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 37816224
use this for the second one :
  var queryString1 = '';
      var dataUrl1 = '';

      function onLoadCallback1() {
        if (dataUrl1.length > 0) {
          var query = new google.visualization.Query(dataUrl1);
          query.setQuery(queryString1);
          query.send(handleQueryResponse1);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_statsState['cyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_statsState['greece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_statsState['patriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_statsState['violations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_statsState['fyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_statsState['caucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_statsState['cyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw1(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart2'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '-5,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: '<?php echo $row_rs_congress['STATE']; ?> Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse1(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      //google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback1);

Open in new window

0
 

Author Comment

by:marcoullis
ID: 37816244
tried your suggestion, but same result.

here is the code as it stands now...

<table>
      <tr>
      <td width="300">
        
        
         <div id="chart1"></div>
         <div id="chart2"></div>

   <script type="text/javascript">
      var queryString = '';
      var dataUrl = '';

      function onLoadCallback() {
        if (dataUrl.length > 0) {
          var query = new google.visualization.Query(dataUrl);
          query.setQuery(queryString);
          query.send(handleQueryResponse);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_congress['issueGreece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_congress['issuePatriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_congress['issueViolations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_congress['issueFyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_congress['issueCaucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart1'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '-5,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: 'Congressional Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback);

    </script>         
    </td>
        
    <td width="300">
     
     
     <script type="text/javascript">
      var queryString1 = '';
      var dataUrl1 = '';

      function onLoadCallback1() {
        if (dataUrl1.length > 0) {
          var query = new google.visualization.Query(dataUrl1);
          query.setQuery(queryString1);
          query.send(handleQueryResponse1);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_statsState['cyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_statsState['greece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_statsState['patriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_statsState['violations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_statsState['fyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_statsState['caucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_statsState['cyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw1(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart2'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '-5,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: '<?php echo $row_rs_congress['STATE']; ?> Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse1(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      //google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback1);
    </script>                 
            </td>
            </tr></table>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 37816267
please provide a link to see your page
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:marcoullis
ID: 37816268
Made another minor change with the <div> tags
but the result is the same...

basically its showing the data of the second with
the title of the first... very strange.

 <table>
      <tr>
      <td width="300">
        
        
         <div id="chart1"></div>
         

   <script type="text/javascript">
      var queryString = '';
      var dataUrl = '';

      function onLoadCallback() {
        if (dataUrl.length > 0) {
          var query = new google.visualization.Query(dataUrl);
          query.setQuery(queryString);
          query.send(handleQueryResponse);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_congress['issueGreece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_congress['issuePatriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_congress['issueViolations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_congress['issueFyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_congress['issueCaucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart1'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '0,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: 'Congressional Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback);

    </script>         
    </td>
        
    <td width="300">
     <div id="chart2"></div>
     
     <script type="text/javascript">
      var queryString1 = '';
      var dataUrl1 = '';

      function onLoadCallback1() {
        if (dataUrl1.length > 0) {
          var query = new google.visualization.Query(dataUrl1);
          query.setQuery(queryString1);
          query.send(handleQueryResponse1);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_statsState['cyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_statsState['greece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_statsState['patriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_statsState['violations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_statsState['fyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_statsState['caucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_statsState['cyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw1(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart2'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '0,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: '<?php echo $row_rs_congress['STATE']; ?> Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse1(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      //google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback1);
    </script>                 
            </td>
            </tr>
            </table>

Open in new window

0
 

Author Comment

by:marcoullis
ID: 37816271
0
 
LVL 82

Expert Comment

by:leakim971
ID: 37816288
line 97 : draw1(dataTable);
line 121 : vis.draw1(dataTable, options);
line 129 : draw1(response.getDataTable());
0
 

Author Comment

by:marcoullis
ID: 37816307
Now it showing title and data from the first, but not the second chart at all.

 <table>
      <tr>
      <td width="300">
        
        
         <div id="chart1"></div>
         

   <script type="text/javascript">
      var queryString = '';
      var dataUrl = '';

      function onLoadCallback() {
        if (dataUrl.length > 0) {
          var query = new google.visualization.Query(dataUrl);
          query.setQuery(queryString);
          query.send(handleQueryResponse);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_congress['issueGreece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_congress['issuePatriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_congress['issueViolations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_congress['issueFyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_congress['issueCaucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_congress['issueCyprus']; ?>);

          draw(dataTable);
        }
      }

      function draw(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart1'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '0,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: 'Congressional Scorecard'
        };
        vis.draw(dataTable, options);
      }

      function handleQueryResponse(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw(response.getDataTable());
      }

      google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback);

    </script>         
    </td>
        
    <td width="300">
     <div id="chart2"></div>
     
     <script type="text/javascript">
      var queryString1 = '';
      var dataUrl1 = '';

      function onLoadCallback1() {
        if (dataUrl1.length > 0) {
          var query = new google.visualization.Query(dataUrl1);
          query.setQuery(queryString1);
          query.send(handleQueryResponse1);
        } else {
          var dataTable = new google.visualization.DataTable();
          dataTable.addRows(7);

          dataTable.addColumn('number');
          dataTable.setValue(0, 0, <?php echo $row_rs_statsState['cyprus']; ?>);
          dataTable.setValue(1, 0, <?php echo $row_rs_statsState['greece']; ?>);
          dataTable.setValue(2, 0, <?php echo $row_rs_statsState['patriarchate']; ?>);
          dataTable.setValue(3, 0, <?php echo $row_rs_statsState['violations']; ?>);
          dataTable.setValue(4, 0, <?php echo $row_rs_statsState['fyrom']; ?>);
          dataTable.setValue(5, 0, <?php echo $row_rs_statsState['caucus']; ?>);
          dataTable.setValue(6, 0, <?php echo $row_rs_statsState['cyprus']; ?>);

          draw1(dataTable);
        }
      }

      function draw1(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart2'));
        var options = {
          chxl: '0:|CYP|GRE|PAT|VIO|FYR|CAU',
          chxp: '0,1,2,3,4,5,6',
          chxr: '0,0,5',
          chxs: '0,676767,10.5,0,lt,676767',
          chxtc: '',
          chxt: 'x',
          chs: '250x250',
          cht: 'r',
          chco: 'FF0000',
          chds: '0,5',
          chd: 't:4,5,3,2,5,3,4',
          chdl: '',
          chls: '2,4,0',
          chma: '0,5|5',
          chm: 'B,FF000080,0,0,0',
          chtt: '<?php echo $row_rs_congress['STATE']; ?> Scorecard'
        };
        vis.draw1(dataTable, options);
      }

      function handleQueryResponse1(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
          return;
        }
        draw1(response.getDataTable());
      }

      //google.load("visualization", "1", {packages:["imagechart"]});
      google.setOnLoadCallback(onLoadCallback1);
    </script>                 
            </td>
            </tr>
            </table>

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37816320
my bad, replace
on line 121 : vis.draw1(dataTable, options);
by this one : vis.draw(dataTable, options);
0
 

Author Comment

by:marcoullis
ID: 37816329
bingo!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Send form to asp server side 6 26
Read text on Table 7 27
Check input text, Number 6 30
Scroll 5 news at a time using vticker 2 8
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question