Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have several things giving you problems. See this fiddle: <a href="http://jsfiddle.net/nbwN9/1/" rel="nofollow">http://jsfiddle.net/nbwN9/1/</a></p> <p>First, I don't think your json is in the proper format for a 2 series plot. You have two arrays of data just butted up to each other rather than in another array. The linked fiddle corrects that (and stuffs it into a var since the getJSON() call will fail within jsFiddle). Each point is an array of (x,y) coords. Each series.data is an array of points. Your json will need to be an array of series.data arrays. So we're looking at nested arrays 3 deep.</p> <p>Second, you seem to have a malformed set of chart options. Most notable is that your series node (with name and data) is inside your plotOptions node when it should be outside of it. And that series node is not terminated properly.</p> <p>Third, once you get your json data and your chart options formatted correctly, accessing the json array is done like so:</p> <pre><code> series: [{ name: 'Night', data: json[0] }, { name: 'Day', data: json[1] }] </code></pre> <p>The array is 0-based (so the first record will be indexed with a 0, second record with a 1, etc) and is access using the brackets <strong>[]</strong> not parentheses <strong>()</strong></p> <p>Sorry, I renamed one of your series to "Day" so I could see the difference in the chart.</p> <p>As far as the PHP script... try this:</p> <pre><code> $result1 = mysql_query("SELECT round(AVG(d_internal_duct_return),0) AS 'avg_return', round(AVG(d_evap_pre_humidity),0) AS 'avg_hum' FROM pheom.pheom_gb WHERE timestamp between subdate(curdate(), interval 2 month) and curdate() AND HOUR(Timestamp) NOT BETWEEN 9 AND 22 GROUP BY DAY(Timestamp) ORDER BY Timestamp"); $ret1 = array(); while($item = mysql_fetch_array($result1)) { $avg_return1 = $item['avg_return']; $avg_hum1 = $item['avg_hum']; $ret1[] = array($avg_return1,$avg_hum1); } $result2 = mysql_query("SELECT round(AVG(d_internal_duct_return),0) AS 'avg_return', round(AVG(d_evap_pre_humidity),0) AS 'avg_hum' FROM pheom.pheom_gb WHERE timestamp between subdate(curdate(), interval 2 month) and curdate() AND HOUR(Timestamp) BETWEEN 9 AND 22 GROUP BY DAY(Timestamp) ORDER BY Timestamp"); $ret2 = array(); while($item = mysql_fetch_array($result2)) { $avg_return2 = $item['avg_return']; $avg_hum2 = $item['avg_hum']; $ret2[] = array($avg_return2,$avg_hum2); } echo json_encode(array($ret1,$ret2), JSON_NUMERIC_CHECK); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload