DBnR
DBnR

Reputation: 175

Adding points to Highcharts 3D scatter chart after the chart has loaded

I'm trying to automatically add data points to a 3D scatter chart using ajax. The problem is, I can't seem to get the chart to accept my y-axis data point I get from the ajax script. The x and z values it accepts just fine, but not the y-value. But if I input the y-value as a plain number, it works just fine.. There's some simple little thing that's wrong, but I just can't figure it out...

Here's a modified version of the Highcharts 3D demo to illustrate what I'm on about: JSFiddle

Here's the relevant code:

var result = "5,3,8"
var res = result.split(",");

var xval = res[0];
var yval = res[1];
var zval = res[2];

function works() {
    var chart = $('#container').highcharts()
    chart.series[0].addPoint([xval, 6, zval]);
}

function doesntwork() {
    var chart = $('#container').highcharts()
    chart.series[0].addPoint([xval, yval, zval]);
}

Normally I would get the result variable from the ajax request.

Upvotes: 1

Views: 302

Answers (1)

Gorazd Zizek
Gorazd Zizek

Reputation: 28

Parse values to float.

var xval = parseFloat(res[0]);
var yval = parseFloat(res[1]);
var zval = parseFloat(res[2]);

Upvotes: 1

Related Questions