score:2

Accepted answer

can't you change that "almost" json to "another" json? maybe something like this:

[{
    "name":'station 1',
    "data": [ [360191600,398.625], [360191600,398.625], [360191600,398.625] ... [360191600,398.625] ]
}, {
    "name":'station 2',
    "data": [ [360191600,398.625], [360191600,398.625], [360191600,398.625] ... [360191600,398.625] ]
}]

if not, you have to add some parsing for your values, example:

data = json.parse(data);
var names = [];
$.each(data, function (i, ligne) {
    var ind = names.indexof(ligne.name),
        splited = ligne.data.split(','),
        x = parsefloat(splited[0]),
        y = parsefloat(splited[1]);
    if (ind == -1) {
        /*series name spotted first time need to add new series */
        ind = names.push(ligne.name) - 1;
        options.series.push({
            data: [],
            name: ligne.name
        });
    } 
    if(!isnan(x) && !isnan(y)){
        options.series[ind].data.push([x,y]);    
    }
});

and working jsfiddle: http://jsfiddle.net/3bqne/40/


Related Query

More Query from same tag