score:1

I eventually made it work with the following solution:

In the analysisajax.php script, I no longer generate the yaxis. I only send name and data.

The code to generate the graph now looks like this:

    var updateChart = function(json) {
        //console.log(json)
        var options = {
            chart: {
                renderTo: 'graph',
                type: 'line',
                zoomType: 'x'
            },
            title: { text: null },
            yAxis:[],
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'bottom'
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                    pointStart: 0
                }
            },
            series: [],
            tooltip: { shared: true }
        }

        var chart = new Highcharts.Chart(options);

        // update axis and series
        for (i=0; i<json.length; i++) {
            // add axis
            chart.addAxis({ title: { text: json[i].name } });

            // add serie
            var a = chart.series.length;
            var seriesOptions = {
                name: json[i].name,
                data: json[i].data,
                yAxis: a
            }
            chart.addSeries(seriesOptions,true);
            chart.options.series.push(seriesOptions);       
        }
    }

    $(document).ready(function() {
        $('#f').change(function() {
            var requestParams = { f: $('#f').val() };
            $.post('analysisajax.php', requestParams, updateChart);             
            //return false;
        });
    });    

Related Query

More Query from same tag