javascript - Highcharts addPoint function show nothing -
in first case apologize bad english i'm french :d
so tried show timed data on highchartsjs.
i try receive data using ajax , made function add point want.
but when try load see information on cursor no point shown ! :/
here success function on ajax request :
success: function(resultat){ function addpoint(){ var chart = $('#graphresult').highcharts(); for(i in resultat){ chart.series[0].addpoint([date.utc(year, month, day, resultat[i]["time"].split(":")[0]), resultat[i]["value"]], true); } } $('#graphresult').highcharts({ chart: { type: 'spline', events: { load: addpoint } }, title: { text: 'température du jour' }, xaxis: { type: 'datetime', datetimelabelformats: { // don't display dummy year minute: '%h:%m', hour: '%h:%m', }, title: { text: 'heure' } }, yaxis: { title: { text: 'température (°c)' }, min: 0 }, tooltip: { headerformat: '<b>{series.name}</b><br>', pointformat: '{point.y:.2f} °c' }, plotoptions: { spline: { marker: { enabled: true } } }, series: [{ name: "température du " + string(day) + "/" + string(month) + "/" + string(year), }] }); }
as can see, have information no point displayed : http://puu.sh/kwfnv/ad6302810a.png
as said in comments, problem in data returned server.
this json:
[{"time":"09:00:00","value":"25"},{"time":"10:00:00","value":"30"}]
the "value" string, have parse float:
chart.series[0].addpoint( [date.utc(year, month, day, resultat[i]["time"].split(":")[0]), parsefloat(resultat[i]["value"])], true );
fiddle: http://jsfiddle.net/69k80l58/4/
Comments
Post a Comment