你可以自己测试一下。默认为currentIndex为3,点击更换timeline为全新的且currentIndex也为3。
我认为问题出现在:currentIndex : 3 这个,触发了TIMELINE_CHANGED
TIMELINE_CHANGED为0的时候不存在这个问题。
_setTimelineOption: function (option) {
this._timeline && this._timeline.dispose();
var Timeline = require('./component/timeline');
var timeline = new Timeline(this._themeConfig, this._messageCenter, this._zr, option, this);
this._timeline = timeline;
this.component.timeline = this._timeline;
return this;
},
这个:
this._timeline && this._timeline.dispose();
和
var timeline = new Timeline(this._themeConfig, this._messageCenter, this._zr, option, this);
echarts没有清除。你说据我的业务逻辑来。
我尝试使用如下代码,,不行的
var timechangedfunction = function(s){
$.post(indexurl, {'csrf_key' : '{{ csrf_key }}', 'csrf_token' : '{{ csrf_token }}'}, function(data){
myChart.un(echartsConfig.EVENT.TIMELINE_CHANGED, timechangedfunction);
myChart.setOption({
timeline : {
data: $.parseJSON(data.timeline_data),
label : {
formatter : function(s) {
return s;//s.slice(0, 4);
}
},
currentIndex : 3,
controlPosition : 'none'
}
});
myChart.on(echartsConfig.EVENT.TIMELINE_CHANGED, timechangedfunction);
});
};
myChart.on(echartsConfig.EVENT.TIMELINE_CHANGED, timechangedfunction);
还请指教。