Hi,

I am having trouble drawing two charts on same page from two different 
sheets (both published). 

Only one is drawn and after a while i get the following message: "Error in 
query: Request timed out"

Here is my code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
  
  
    <link rel="stylesheet" href="css/style.css">
    
    <!--Load the AJAX API-->
    <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>
    
    <!--eNPS-->
    <script type="text/javascript">


      // Load the Visualization API and the piechart package.
      google.charts.load('current', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.charts.setOnLoadCallback(drawEnpsChart);

      // Set a callback to run when the Google Visualization API is loaded.
      google.charts.setOnLoadCallback(drawCnpsChart);
        
        
      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws eNPS
    function drawEnpsChart() {
      var queryString_enps = encodeURIComponent('select A,B');

      var query_enps = new google.visualization.Query( 
'https://docs.google.com/spreadsheets/d/1Zga-AlllXXR4Q1W27GWliTS2QjtqDK-LibMNC5-ypnw/gviz/tq?sheet=Sheet1&headers=1&tq='
 
+ queryString_enps);
      query_enps.send(handleSampleDataQueryResponse);
    
        //From share option in google sheet

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

      var data = response.getDataTable();
      var chart = new 
google.visualization.LineChart(document.getElementById('chart_div_enps'));
      chart.draw(data, { 
          height: 400,
          title: 'eNPS',
        animation:{
            startup: true,
            duration: 1000,
            easing: 'out',
        },
      });
    }
    }
        
      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws cNPS
    function drawCnpsChart() {
      var queryString_cnps = encodeURIComponent('select A,B');

      var query_cnps = new google.visualization.Query( 
'https://docs.google.com/spreadsheets/d/1_e6188Wr3VOH261hFcbREh6uosXF6i35lfLxYvLR0vk/gviz/tq?sheet=Sheet1&headers=1&tq='
 
+ queryString_cnps);
      query_cnps.send(handleSampleDataQueryResponse);
    
        //From share option in google sheet

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

      var data = response.getDataTable();
      var chart = new 
google.visualization.LineChart(document.getElementById('chart_div_cnps'));
      chart.draw(data, { 
          height: 400,
          title: 'cNPS',
        animation:{
            startup: true,
            duration: 1000,
            easing: 'out',
        },
      });
    }    
}
    </script>
    
    
</head>
  
    
<body>
    

      
      
<div>
    <!--Div with cNPS chart-->
    <div id="chart_div_enps"></div>
</div>

<div>
    <!--Div with cNPS chart-->
    <div id="chart_div_cnps"></div>
</div>

    
    
    </body>

Any suggestions to how i can draw both charts on the page?

/Mikkel

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/a9e280db-e588-4a2d-808a-165e117c74b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to