Thank you for your reply Daniel,

I wonder if I could ask a favour? I've almost got my code dynamically
adding to each series using loops/ifs etc. However I've got to the point
where I can't figure out what is wrong with the chart javascript that's
generated. Do you have any idea what's happening with the code below?

*The error message I'm getting in the console is.*... " Uncaught (in
promise) Error: Row given with size different than 6 (the number of columns
in the table)."

*Here's the output generated by my php:*

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js
"></script>
    <script type="text/javascript">
      google.charts.load('current', {packages: ['corechart', 'line']});
google.charts.setOnLoadCallback(drawBasic);

var columnCount = 0;
function drawBasic() {

      var data = new google.visualization.DataTable();

      data.addColumn('string', 'tdate');
data.addColumn('string', 'ttime');
data.addColumn('number', 'Living Room Out Box');
data.addColumn('number', 'Living Room In Box');
data.addColumn('number', 'Future Bathroom');
data.addColumn('number', 'Outside Temperature');
var columnCount = data.getNumberOfColumns();
var columnArray = [];
for (i = 0; i < columnCount; i++) {
columnArray.push(data.getColumnLabel(i));
}
data.addRows([['2017-06-14','22:59:52',,,,18],['2017-06-14','23:00:23',,,25,],['2017-06-14','23:00:54',,,,18],['2017-06-14','23:01:24',,,25,],['2017-06-14','23:01:55',,,,18],['2017-06-14','23:02:26',,,25,],['2017-06-14','23:02:57',,,,18],['2017-06-14','23:03:28',,,25,],['2017-06-14','23:03:59',,,,18],['2017-06-14','23:04:30',,,25,],['2017-06-14','23:05:01',,,,18],['2017-06-14','23:05:31',,,25,],['2017-06-14','23:06:02',,,,18],['2017-06-14','23:06:33',,,25,],['2017-06-14','23:07:04',,,,18],['2017-06-14','23:07:35',,,25,],['2017-06-14','23:08:06',,,,18],['2017-06-14','23:08:37',,,25,],['2017-06-14','23:09:07',,,,18],['2017-06-14','23:09:38',,,25,],['2017-06-14','23:10:09',,,,18],['2017-06-14','23:10:40',,,25,],['2017-06-14','23:11:11',,,,18],['2017-06-14','23:11:42',,,25,],['2017-06-14','23:12:13',,,,18],['2017-06-14','23:12:44',,,25,],['2017-06-14','23:13:14',,,,18],['2017-06-14','23:13:45',,,25,],['2017-06-14','23:14:16',,,,18],['2017-06-14','23:14:47',,,25,],['2017-06-14','23:15:18',,,,18],['2017-06-14','23:15:49',,,25,],['2017-06-14','23:16:20',,,,18],['2017-06-14','23:16:51',,,25,],['2017-06-14','23:17:21',,,,18],['2017-06-14','23:17:52',,,25,],['2017-06-14','23:18:23',,,,18],['2017-06-14','23:18:54',,,25,],['2017-06-14','23:19:25',,,,18],['2017-06-14','23:19:56',,,25,],['2017-06-14','23:20:27',,,,18],['2017-06-14','23:20:58',,,25,],['2017-06-14','23:21:28',,,,18],['2017-06-14','23:21:59',,,25,],['2017-06-14','23:22:30',,,,18],['2017-06-14','23:23:01',,,25,],['2017-06-14','23:23:32',,,,18],['2017-06-14','23:24:03',,,25,],['2017-06-14','23:24:34',,,,18],['2017-06-14','23:25:04',,,25,],['2017-06-14','23:25:35',,,,18],['2017-06-14','23:26:06',,,25,],['2017-06-14','23:26:37',,,,18],['2017-06-14','23:27:08',,,25,],['2017-06-14','23:27:39',,,,18],['2017-06-14','23:28:10',,,25,],['2017-06-14','23:28:40',,,,18],['2017-06-14','23:29:11',,,25,],['2017-06-14','23:29:42',,,,18],['2017-06-14','23:30:13',,,25,],['2017-06-14','23:30:44',,,,18],['2017-06-14','23:31:15',,,25,],['2017-06-14','23:31:46',,,,18]]);
      var options = {
    curveType: 'function',
        hAxis: {
          title: 'Time'
        },
        vAxis: {
          title: 'Temperature'
        }
      };
      var myView = new google.visualization.DataView(data);
      var chart = new
google.visualization.LineChart(document.getElementById('chart_div'));

      chart.draw(data, options);
      //document.write("Column array value: " + columnArray[1]);
    }
   //

    </script>
<div id="chart_div" style="width: 1500px; height: 800px"></div>


Thanks for any help at all!!! Matt

On 1 June 2017 at 15:08, 'Daniel LaLiberte' via Google Visualization API <
[email protected]> wrote:

> Hi Matt,
>
> Currently, you will need to put each of your zones in a separate column.
> I don't know if there is a way to do this with SQL, but you could do it in
> JavaScript with a simple loop over your data as you create another
> datatable.
>
> At some point in the future, it would probably be convenient if we had a
> 'series' role, which you could apply to your zones column to have it
> automatically create the separate series for each zone.
>
> On Wed, May 31, 2017 at 9:19 AM, Matt K90 <[email protected]> wrote:
>
>> Hi there,
>>
>> I'll hold my hands up right now and say that I'm new to Google Charts, so
>> apologies in advance if this is a noob question!
>>
>> I am trying to create a line chart of temperature information, collected
>> by Raspberry Pi, from within my house. The data is stored in a MySQL
>> database in the following format:
>>
>>       *  tdate                ttime        zone
>>        temperature*
>>         2017-05-14 17:24:17 Living Room Out Box 19
>> 2017-05-14 17:24:23 Living Room In Box         20
>> 2017-05-14 17:24:31 Living Room Out Box 20
>> 2017-05-14 17:24:42 Living Room In Box         20
>> 2017-05-14 17:24:48 Living Room Out Box 20
>> 2017-05-14 17:24:53 Living Room In Box         20
>> 2017-05-14 17:24:59 Outside                     15
>> 2017-05-14 17:25:05 Living Room In Box         20
>> 2017-05-14 17:25:12 Living Room Out Box 20
>> 2017-05-14 17:25:18 Living Room In Box         20
>> 2017-05-14 17:25:23 Outside                      15
>> 2017-05-14 17:25:29 Living Room In Box         20
>> 2017-05-14 17:25:35 Living Room Out Box 20
>> 2017-05-14 17:25:41 Living Room In Box         20
>>
>>
>> I am trying to plot a graph that has a line for each zone, similar to
>> below:
>>
>>
>> <https://lh3.googleusercontent.com/-lF-dlnsaTiA/WS68JBGNQ7I/AAAAAAAAy8E/GJ5sTZK7GrMf3T50Um86et5dg8uJNLRAgCLcB/s1600/Screen%2BShot%2B2017-05-31%2Bat%2B13.38.16.png>
>>
>>
>>
>> I cannot fathom how I need to organise my DataTable in order to account
>> for the way in which the data is being returned. I will be adding
>> thermometers to the house as I progress with the renovations, so I'd like
>> to be able to cater for data where a line is plotted that may start half
>> way through the results set  when that thermometer comes online (see
>> "Outside" zone for example).
>>
>> In order to set the columns and data in the way I've seen in all
>> tutorials and examples, I would need to know the order in which they appear
>> in the database. However the data is not in that format as I've added
>> thermometers as I've progressed, plus due to the way in which the
>> thermometers work they might all be writing at slightly different times, so
>> I cannot easily order the data to create the table orientation below
>> (example I've found online showing add rows used when order is known):
>>
>> data.addColumn('number', 'Day');
>>       data.addColumn('number', 'Guardians of the Galaxy');
>>       data.addColumn('number', 'The Avengers');
>>       data.addColumn('number', 'Transformers: Age of Extinction');
>>
>>       data.addRows([
>>         [1,  37.8, 80.8, 41.8],
>>         [2,  30.9, 69.5, 32.4],
>>         [3,  25.4,   57, 25.7],
>>         [4,  11.7, 18.8, 10.5],
>>         [5,  11.9, 17.6, 10.4],
>>         [6,   8.8, 13.6,  7.7],
>>         [7,   7.6, 12.3,  9.6],
>>         [8,  12.3, 29.2, 10.6],
>>         [9,  16.9, 42.9, 14.8],
>>         [10, 12.8, 30.9, 11.6],
>>         [11,  5.3,  7.9,  4.7],
>>         [12,  6.6,  8.4,  5.2],
>>         [13,  4.8,  6.3,  3.6],
>>         [14,  4.2,  6.2,  3.4]
>>
>> This might just be down to the way in which I need to group or order the
>> data in my SQL SELECT statement. But I can't seem to figure it out!! Is
>> there a means by which I can group/order/add the data in the DataTable
>> object to achieve what I need to do/see?
>>
>> Any help would be very much appreciated!
>>
>> Thanks! Matt
>>
>>
>>
>> --
>> 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 google-visualization-api@googl
>> egroups.com.
>> Visit this group at https://groups.google.com/grou
>> p/google-visualization-api.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/google-visualization-api/20a2e9aa-04e8-48d6-9a75-536221
>> c457fc%40googlegroups.com
>> <https://groups.google.com/d/msgid/google-visualization-api/20a2e9aa-04e8-48d6-9a75-536221c457fc%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>
> [email protected] <[email protected]>   5CC, Cambridge MA
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Visualization API" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/google-visualization-api/IB-y-DvK1g8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> 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/CAOtcSJPBno-oXLjkt4CrfMw1QYSDw7iT3CFvRTtEu
> ObEAjH9DA%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJPBno-oXLjkt4CrfMw1QYSDw7iT3CFvRTtEuObEAjH9DA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CABE_m6aZjG%3D60LRXYSfQ9nwSKWO%3Ds1r-T55SFbY6pD5N2Xs_pA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to