Highcharts.js nicht machen das Diagramm, es sagt error "Cannot read property' - Serie,' of undefined"

Ich denke, es ist weil meine Globale var chart wurde noch nicht festgelegt, doch wenn meine Funktion requestData genannt wird.

Dies ist mein code von highcharts innerhalb einer $(document).ready(function()

        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                defaultSeriesType: 'spline',
                marginRight: 130,
                marginBottom: 25,
                events: {
                load: requestData()
                }
            },
            title: {
                text: 'Reporte PMU',
                x: -20 //center
            },
            subtitle: {
                text: '',
                x: -20
            },
            xAxis: {
                type: 'datetime',
                tickPixelInterval: 150,
                maxZoom : 20 * 1000,
                title: {
                  text: 'tiempo'
                },
                labels : { y : 0, rotation: -60 }
            },
            yAxis: {
                title: {
                  text: 'Amount'
                },
                plotLines: [{
                  value: 0,
                  width: 1,
                  color: '#808080'
                }]
            },
            tooltip: {
                formatter: function() {
                  return '<b>'+ this.series.name +'</b><br/>'+
                  this.x +': '+ this.y;
                }
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -10,
                y: 100,
                borderWidth: 0
            },
            series: [{
                name: 'serieTension',
                data: []
            }]
        });     
    });

und das ist mein requestData ()

        $.ajax({                        
            url: 'data2.php', 
            success: function(point) {
                var series =chart.series[0],
                shift = series.data.length > 20; //shift if the series is longer than 20

                //add point
                chart.series[0].addPoint(point, true, shift);

                setTimeout(requestData, 1000);
            },
            cache : false
        });
    }

InformationsquelleAutor rrey | 2013-07-25

Schreibe einen Kommentar