ThomasP
ThomasP

Reputation: 93

use multiple json calls for drawing multiple lines on highcharts php

I'm pulling my hairs since hours...to create multiple lines highstocks by calling php script generating the JSON data

I've a php/javascript file that downloads JSON data containing 2 series. look here

Then, in my php file creating the highchart, I've the following code to display graph of a probe ($sonde_id): see fiddle: the first serie "average" is with the average value, the second is a range with min/max. I can scroll over the time/zoom etc... the refresh works. This is very slow for another known problem, but it works.

Now my problem us that I'd like to display multiple lines from different probes ($sonde_id).

I tried the following code for charting probe 23,22 & 24; by simply multiplying the json.get but that does not work

            var url = 'sonde_exp_json.php?sonde_id=23&callback=?' ; 
    $.getJSON(url, function (json_data_23) {
        console.log (json_data_23.average);
        options.series[0].data=json_data_23.average;
        }); //end getJSON
    url = 'sonde_exp_json.php?sonde_id=22&callback=?' ; 
    $.getJSON(url, function (json_data_22) {
        options.series[1].data =  json_data_22.average;
        }); //end getJSON   
    url = 'sonde_exp_json.php?sonde_id=24&callback=?' ; 
    $.getJSON(url, function (json_data_24) {
        options.navigator.series = json_data_24.average;
        options.series[2].data =  json_data_24.average;
        }); //end getJSON       

error is "ncaught SyntaxError: Unexpected identifier " after the line options.series[0].data.=json_data_23.average;

I don't understand the problem. I'm totally lost with these objects/arrays/json and structure to display multiple lines on same charts. I read many others answers, but I miss something

Thank you

Upvotes: 0

Views: 970

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

See this Highstock example - series are loaded from different calls and it works fine.

Upvotes: 1

Related Questions