javascript - Highcharts live graph: Accessing Datetime data returns an [Object] instead of [Datetime, Int] -
i created minimal reproduction of problem, create easy help me figure out.
this have: http://jsfiddle.net/tdw7e/1/
$(function () { $(document).ready(function () { highcharts.setoptions({ global: { useutc: false } }); var chart; $('#container').highcharts({ chart: { type: 'spline', //animation: highcharts.svg, // don't animate in old ie marginright: 10, events: { load: function () { // set updating of chart each sec var series = this.series[0]; setinterval(function () { var x = (new date()).gettime(), // current time y = math.random(); series.addpoint([x, y], true, true); document.getelementbyid('dbg').innerhtml = series.tostring(); }, 1000); } } }, xaxis: { type: 'datetime', tickpixelinterval: 150 }, series: [{ name: 'random data', data: (function () { // generate array of random info var info = [], time = (new date()).gettime(), i; (i = -19; <= 0; i++) { data.push({ x: time + * 1000, y: math.random() }); } homecoming data; })() }] }); }); }); html:
<script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> <div id="dbg" style="min-width: 310px; height: 400px; margin: 0 auto"></div> i edited live chart demo, write value of info sec div. trying perform check create sure recent datetime value in graph not recent in database. cannot perform check because should array of [datetime, int] becomes array of [object].
any help appreciated!
first of all, in illustration using series array of objects.
second thing, each of points object, otherwise couldn't utilize illustration point.update() update new options etc.
third thing, in illustration creating points as:
data.push({ x: time + * 1000, y: math.random() }); which object, not array.
if want actual point, use: series.options.data, , if using proper format (as said) utilize this: http://jsfiddle.net/tdw7e/4/
javascript datetime highcharts live
No comments:
Post a Comment