0

StockChart当我使用配置对象初始化我的 HighCharts 时,对象中的series参数设置为null在初始化之后。为什么是这样?

代码

//object
var myClass = {
    chartConfig: {
       //some highcharts config

       //some extra params
       url: 'getData.php'
    }
};

myClass.prototype.renderChart = function() {
    console.log(this.chartConfig.series);
    this.chart = new Highcharts.StockChart(this.chartConfig);
    console.log("=======================");
    console.log(this.chartConfig.series);
};

myClass.prototype.getSeriesData = function() {
    var self = this;
    $.getJSON(self.chartConfig.url, function(data) {
        self.chartConfig.series = data;
    });
};

var test = new myClass();
test.getSeriesData();
test.renderChart();

输出

[Object, Object, Object, animation: false]
=======================
null 
4

1 回答 1

3

将此行替换this.chart = new Highcharts.StockChart(this.chartConfig);this.chart = new Highcharts.StockChart($.extend({},this.chartConfig));

于 2013-09-25T14:44:22.450 回答