Beispiel #1
0
 _mergeOption: function () {
     if (this._mergeOptionFlag && this._mergedOptions){
         this._mergedOptions = helper.merge(this._mergedOptions , this._options);
     }else{
         this._mergedOptions = this._options;
     }
     this.originOptions = helper.merge(helper.clone(this._defaultOptions) , this._mergedOptions);
     var component , prop , renderer;
     // 检查renderer类型。
     var rendererType = this.originOptions.chart.renderer;
     if (this.renderer){
         var oldType = this.renderer.type;
         if (oldType !== rendererType){
             this.renderer.destroy();
             for (prop in this._components) { this._components[prop].destroy(); }
             this._components = {};
             for (prop in this._chartPlots) { this._chartPlots[prop].destroy(); }
             this._chartPlots = {};
             this.dom.innerHTML = ""
             this.renderer = ChartFactory.createRenderer(rendererType , this.dom);
         }
     }else{
         this.renderer = ChartFactory.createRenderer(rendererType , this.dom);
     }
     // 更新options
     for (prop in this.originOptions) {
         if (this._components[prop]){
             this._components[prop].options(this.originOptions);
         }else{
             renderer = ChartFactory.createRenderer(this.renderer.type , this._getComponentGroup());
             component = ChartFactory.createComponent(prop , this , renderer);
             if (component){
                 this._components[prop] = component;
                 this._enterComponents.push(component);
             }
         }
     }
     for (prop in this._chartPlots) {
         this._chartPlots[prop].options(this.originOptions);
     }
 } ,
Beispiel #2
0
 _performData: function () {
     var header , data , plotTypes , plot , type , i;
     // 准备数据
     if (!this._data){
         this.originData = null;
     }else{
         if (oop.is(this._data , Array)){
             header = this._data[0];
             data = this._data.slice(1);
             // 一维数组,转为二维结构。
             if (!oop.is(header , Array)){
                 header = [header];
                 data = [data];
             }
             this.originData = {
                 header: header ,
                 data: data
             }
         } else if (typeof this._data === "object") {
             header = this._data.header;
             data = this._data.data;
             if (!header || !data || !oop.is(header , Array) || oop.is(data , Array)){
                 this.originData = null;
             }else{
                 this.originData = data;
             }
         } else {
             this.originData = null;
         }
     }
     // 解析header
     plotTypes = {};
     if (this.originData){
         header = this.originData.header;
         data = this.originData.data;
         for (i = 0; i < header.length; i++) {
             if (header[i].plotType){
                 plotTypes[header[i].plotType] = true;
             }
         }
     }
     // 更新或删除plot
     for (type in this._chartPlots) {
         if (plotTypes[type] === true){
             this._chartPlots[type].data(this.originData);
             delete plotTypes[type];
         }else{
             this._chartPlots[type].destroy();
             delete this._chartPlots[type];
         }
     }
     // 创建plot
     var renderer;
     for (type in plotTypes) {
         renderer = ChartFactory.createRenderer(this.renderer.type , this._getChartPlotGroup());
         plot = ChartFactory.createChartPlot(type , this , renderer);
         if (plot){
             this._chartPlots[type] = plot;
             this._enterComponents.push(plot);
         }
     }
     // 更新components
     for (type in this._components) {
         this._components[type].data(this.originData);
     }
 } ,