Your indenting is a bit screwy.  Would be good to move the code into a js
file, and use an editor that knows javascript to format it better for you.

In any case, it looks like after you draw the new data chart, you end that
function before setting up the newData:

    chartnew.draw(datanew);

            });
        newData = datanew;

but you need that newData assignment to be inside the function.

On Tue, Nov 21, 2017 at 5:13 PM, Uwe Dornbusch <uwe.dornbusc...@gmail.com>
wrote:

> Here goes.
>
> <html>
>   <head>
>     <!--Load the AJAX API-->
>     <script type="text/javascript" src="https://www.gstatic.com/
> charts/loader.js"></script>
>     <script type="text/javascript">
>
>       //This is written in 'classic' style as most options are not yet
> implemented in the 'material' style
>       //Load the Visualization API and the corechart package.
>       google.charts.load('current', {'packages':['corechart', 'table'],
> 'language': 'de'});// the language setting to DE is a simple way to get at
> 24 hour time format for the x axis :-)
>        //DanielLaLiberte
>        // global vars to keep track of which data has come back.
>           var oldData = null;
>           var newData = null;
> //DanielLaLiberte
> // Set a callback to run when the Google Visualization API is loaded.
>       google.charts.setOnLoadCallback(drawChartoriginal);
>       google.charts.setOnLoadCallback(drawChartnew);
>      //google.charts.setOnLoadCallback(drawChartDiff);
>
> function drawChartoriginal() {
> //the next line is the link to the Google Sheets which is the following
> URL and which needs to be subtly changed
> //in the format at the end of the link: https://docs.google.com/
> spreadsheets/d/1xzoNFEuwHilog2zNjuKuilUXbHKCFWNHGZsS2zwEojs/edit#gid=
> 678810481.
>
>     var queryoriginal = new google.visualization.Query('ht
> tp://docs.google.com/spreadsheet/tq?key=135RNRlBakQ5aXqsABZpmLE9dVWjt9
> tZiWdCwD3e9RS4&gid=161902447');
>     queryoriginal.setQuery('SELECT A, B');//this selects the columns from
> the spreadsheet
>     queryoriginal.send(function (responseoriginal) {
>         if (responseoriginal.isError()) {
>             alert('Error in query: ' + responseoriginal.getMessage() + ' '
> + responseoriginal.getDetailedMessage());
>             return;
>             }
>         var dataoriginal = responseoriginal.getDataTable();
>         var chartoriginal = new google.visualization.
> ScatterChart(document.getElementById('chartoriginal_div'));
>         chartoriginal.draw(dataoriginal);
>
>             //DanielLaLiberte
>             oldData = dataoriginal;
>             if (newData) drawChartDiff();
>             //DanielLaLiberte
>
>             })};
>
>         function drawChartnew() {
>         var querynew = new google.visualization.Query('ht
> tp://docs.google.com/spreadsheet/tq?key=135RNRlBakQ5aXqsABZpmLE9dVWjt9
> tZiWdCwD3e9RS4&gid=161902447');
>     querynew.setQuery('SELECT A, C');//this selects the columns from the
> spreadsheet
>     querynew.send(function (responsenew) {
>         if (responsenew.isError()) {
>             alert('Error in query: ' + responsenew.getMessage() + ' ' +
> responsenew.getDetailedMessage());
>             return;
>         }
>
>         var datanew = responsenew.getDataTable();
>         var chartnew = new google.visualization.ScatterChart(document.
> getElementById('chartnew_div'));
>
>     chartnew.draw(datanew);
>
>             });
>             //DanielLaLiberte
>              newData = datanew;
>              if (oldData && newData) drawChartDiff();
>            //DanielLaLiberte
>         }
>
>     function drawChartDiff() {
>     var chartDiff = new google.visualization.ScatterChart(document.
> getElementById('chartdiff_div'));
>     var diffData = chartDiff.computeDiff(dataoriginal, datanew);
>     chartDiff.draw(diffData);
>     //};
>     };
>  </script>
>   </head>
>   <body>
>     <!--Div that will hold the pie chart-->
>
>    <div id="chartoriginal_div"></div>
>    <div id="table_div"></div>
>
>
>    Data:
>    <div id="chartnew_div"></div>
>    differencegraph
>    <div id="chartdiff_div"></div>
>
>   </body>
> </html>
>
>
> --
> 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 google-visualization-api+unsubscr...@googlegroups.com.
> To post to this group, send email to google-visualization-api@
> googlegroups.com.
> 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/0bbc0a9e-519f-4919-94dd-
> 6dd855082c1d%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/0bbc0a9e-519f-4919-94dd-6dd855082c1d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
dlalibe...@google.com <dlalibe...@google.com>   5CC, Cambridge MA

-- 
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 google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
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/CAOtcSJOf0zM-U-J2mUosAdz8qv9NRw21yrPtX28uc6yDg8Z2iA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to