javascript - Unable to get HighCharts to run properly pulling from JSON -


i'll start saying i'm new javascript. have worked java , php more anything.

i copied of code example , have tried tinkering run have not had luck. original example in jsfiddle here: http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/stock/demo/compare/

any input appreciated.

<?php echo <<< 'eot' <html> <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>    <script src="https://code.highcharts.com/highstock.js"></script>    <script src="https://code.highcharts.com/exporting.js"></script> </head> <body> eot; require_once('hvst.php'); // generates json file using json_encode(); echo <<< 'eot' function createchart() {          var fields = ['humidity', 'curtemp'];         highcharts.stockchart('container', {              rangeselector: {                 selected: 4             },              yaxis: {                 labels: {                     formatter: function () {                         return (this.value > 0 ? ' + ' : '') + this.value + '%';                     }                 },                 plotlines: [{                     value: 0,                     width: 2,                     color: 'silver'                 }]             },             tooltip: {                 pointformat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',                 valuedecimals: 2,                 split: true             },             series: seriesoptions         });          $.each(fields, function (timestamp, curtemp) {                 $.getjson('chart1.json', function (humidity) {                         seriesoptions[timestamp] = {                                 name: curtemp,                                 data: humidity                         },                         seriescounter += 1;                          if (seriescounter === fields.length) {                                 createchart();                         }                 });         });  };  </script> <div id="container" style="height: 400px; min-width: 400px"></div> </body> </html> eot; ?> 

edit: hvst.php

<?php ini_set('display_errors', 'on'); error_reporting(e_all); //set json header header("content-type: text/json");  include 'dbread.php'; //include 'correlate.php';  // last 5 days $days=5; $resultset1 = readdb('select timestamp,humidity,curtemp public."weatherdata" timestamp > now()-interval \''.$days.' days\';'); $fp = fopen('chart1.json', 'w'); fwrite($fp, json_encode($resultset1,json_pretty_print|json_numeric_check)); fclose($fp); ?> 

here's sample of first few lines json output:

[     {         "timestamp": "2016-11-05 10:10:02.427425",         "humidity": 48,         "curtemp": 46     },     {         "timestamp": "2016-11-05 10:10:03.83401",         "humidity": 48,         "curtemp": 46     }, 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -