WoJ February 2016

Is it possible to change the name of "x" for x data?

I receive data which I would like to chart. Unfortunately, it consist of records like

{
    abcisse: 5,
    ordonnee: 9
}

which I would like to feed into data.

The record above corresponds, in highcharts nomenclature, to

{
    x: 5,
    y: 9
}

Is it possible to inform highcharts that he should be looking for values of x in abcisse and for values of y in ordonnee? Or do I have to postprocess the data and create x and y entries?

Answers


Bobby Orndorff February 2016

You can use an array map function to convert your records to the format need my highcharts. For example, if your data is in an array called myData then you could feed your data to the series.data option using...

$('#container').highcharts({
    ....
    series: [{
        data: myData.map(function (item) {return { x: item.abcisse, y: item.ordonnee}; })
    }]
    ...
});

Post Status

Asked in February 2016
Viewed 2,815 times
Voted 9
Answered 1 times

Search




Leave an answer