Note that there are some explanatory texts on larger screens.

plurals
  1. POGet json data into Highcharts scatter plot
    primarykey
    data
    text
    <p>I cannot get Highcharts to graph a scatter plot of 2 series. Actually, the graph isn't even showing up. Please help me determine what I'm doing wrong. I cannot find a scatter plot example to go off of and I am very new to this. I've got json data from a php file that looks like: </p> <pre><code>[[65,44],[66,37],[67,42],[68,55],[65,50],[65,41],[65,41],[68,41],[69,42],[70,47],[69,55],[67,45],[67,49],[67,53],[67,49],[68,51],[68,55],[68,57],[70,53],[69,66],[68,54],[69,52],[68,48]][[75,36],[72,42],[75,44],[69,56],[72,40],[73,37],[77,34],[77,40],[74,50],[77,45],[77,43],[75,47],[73,52],[73,50],[75,44],[72,54],[71,57],[72,57],[74,55],[74,54],[75,47],[78,45],[75,43]] </code></pre> <p>This should be two series in an (x,y) format. I want to graph these on a scatter plot in HighCharts. My HighCharts code is:</p> <pre><code> &lt;script type="text/javascript"&gt; $(function () { var chart; $(document).ready(function() { $.getJSON("comfortgb1b.php", function(json) { chart = new Highcharts.Chart({ chart: { renderTo: 'container4', type: 'scatter', marginRight: 175, marginBottom: 50 }, title: { text: 'Comfort Level', x: -20 //center }, subtitle: { text: '', x: -20 }, xAxis: { title: { enabled: true, text: 'Temp (F)' }, min: 60, max: 85, startOnTick: true, endOnTick: true, showLastLabel: true }, yAxis: { title: { text: 'Humidity (%RH)' }, min: 30, max: 100 }, plotOptions: { scatter: { marker: { radius: 5, states: { hover: { enabled: true, lineColor: 'rgb(100,100,100)' } } }, states: { hover: { marker: { enabled: false } } }, tooltip: { headerFormat: '&lt;b&gt;{series.name}&lt;/b&gt;&lt;br&gt;', pointFormat: '{point.x} F, {point.y} %RH' } }, series: [{ name: 'Night', data: json(1) }, { name: 'Night', data: json(2) }); }); }); }); &lt;/script&gt; </code></pre> <p>Thanks in advance!</p> <p>The php file that is creating the json data is below. How would I separate these arrays with a comma?</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($ret1, JSON_NUMERIC_CHECK); echo json_encode($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.
 

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