echarts.js 18.6 KB
Newer Older
L
lang 已提交
1
/**
L
lang 已提交
2
 * TODO setTheme
3
 *      axis position 统一处理
L
lang 已提交
4
 *      规范 Symbol 配置和绘制, customPath
L
lang 已提交
5 6
 *
 *      每次 update 只刷新 model 变化的那些 component(需要做依赖收集)
L
lang 已提交
7
 */
L
lang 已提交
8 9
define(function (require) {

L
lang 已提交
10
    var GlobalModel = require('./model/Global');
L
lang 已提交
11
    var ExtensionAPI = require('./ExtensionAPI');
L
lang 已提交
12
    var CoordinateSystemManager = require('./CoordinateSystem');
L
lang 已提交
13

L
Update  
lang 已提交
14 15 16 17 18 19
    var ComponentModel = require('./model/Component');
    var SeriesModel = require('./model/Series');

    var ComponentView = require('./view/Component');
    var ChartView = require('./view/Chart');

L
lang 已提交
20 21
    var scaleClasses = require('./scale/scale');

L
lang 已提交
22
    var zrender = require('zrender');
L
lang 已提交
23
    var zrUtil = require('zrender/core/util');
L
lang 已提交
24 25
    var colorTool = require('zrender/tool/color');
    var env = require('zrender/core/env');
L
lang 已提交
26

27 28
    var each = zrUtil.each;

29 30
    var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component'];

L
lang 已提交
31
    // TODO Transform first or filter first
L
lang 已提交
32 33
    var PROCESSOR_STAGES = ['transform', 'filter', 'statistic'];

L
lang 已提交
34 35 36
    /**
     * @module echarts~ECharts
     */
L
lang 已提交
37 38
    var ECharts = function (dom, theme, opts) {
        opts = opts || {};
L
lang 已提交
39

L
lang 已提交
40 41 42 43 44
        /**
         * @type {HTMLDomElement}
         * @private
         */
        this._dom = dom;
L
lang 已提交
45 46 47 48
        /**
         * @type {module:zrender/ZRender}
         * @private
         */
L
lang 已提交
49 50 51
        this._zr = zrender.init(dom, {
            renderer: opts.renderer || 'canvas'
        });
L
lang 已提交
52

L
lang 已提交
53 54 55 56
        /**
         * @type {Object}
         * @private
         */
L
lang 已提交
57
        this._theme = zrUtil.clone(theme);
L
lang 已提交
58

L
lang 已提交
59 60 61 62
        /**
         * @type {Array.<module:echarts/view/Chart>}
         * @private
         */
L
lang 已提交
63
        this._chartsList = [];
L
lang 已提交
64 65 66 67 68

        /**
         * @type {Object.<string, module:echarts/view/Chart>}
         * @private
         */
L
lang 已提交
69 70
        this._chartsMap = {};

L
lang 已提交
71 72 73 74
        /**
         * @type {Array.<module:echarts/view/Component>}
         * @private
         */
L
lang 已提交
75
        this._componentsList = [];
L
lang 已提交
76 77 78 79 80

        /**
         * @type {Object.<string, module:echarts/view/Component>}
         * @private
         */
L
lang 已提交
81 82
        this._componentsMap = {};

L
lang 已提交
83
        /**
L
lang 已提交
84
         * @type {module:echarts/ExtensionAPI}
L
lang 已提交
85 86
         * @private
         */
L
lang 已提交
87
        this._extensionAPI = new ExtensionAPI(this);
L
lang 已提交
88

L
lang 已提交
89 90 91 92
        /**
         * @type {module:echarts/CoordinateSystem}
         * @private
         */
L
lang 已提交
93
        this._coordinateSystem = new CoordinateSystemManager();
L
lang 已提交
94

L
lang 已提交
95 96 97 98 99
        /**
         * Layout instances
         * @type {Array}
         * @private
         */
L
lang 已提交
100 101 102
        this._layouts = zrUtil.map(layoutClasses, function (Layout) {
            return new Layout();
        });
L
lang 已提交
103 104
    };

L
tweak  
lang 已提交
105 106 107 108
    var echartsProto = ECharts.prototype;
    echartsProto.getDom = function () {
        return this._dom;
    };
L
lang 已提交
109

L
tweak  
lang 已提交
110 111 112
    echartsProto.getZr = function () {
        return this._zr;
    };
L
lang 已提交
113

L
tweak  
lang 已提交
114 115 116
    echartsProto.setOption = function (option, notMerge, refreshImmediately) {
        // PENDING
        option = zrUtil.clone(option, true);
117

L
tweak  
lang 已提交
118 119 120
        each(optionPreprocessorFuncs, function (preProcess) {
            preProcess(option);
        });
L
lang 已提交
121

L
tweak  
lang 已提交
122 123 124 125 126 127 128 129 130
        var ecModel = this._model;
        if (!ecModel || notMerge) {
            ecModel = new GlobalModel(option, null, this._theme);
            this._model = ecModel;
        }
        else {
            ecModel.restoreData();
            ecModel.mergeOption(option);
        }
L
lang 已提交
131

L
tweak  
lang 已提交
132
        this._prepareComponents(ecModel);
L
lang 已提交
133

L
tweak  
lang 已提交
134
        this._prepareCharts(ecModel);
L
lang 已提交
135

L
tweak  
lang 已提交
136
        this.update();
L
lang 已提交
137

L
tweak  
lang 已提交
138 139
        refreshImmediately && this._zr.refreshImmediately();
    };
L
lang 已提交
140

L
tweak  
lang 已提交
141 142 143 144 145 146
    /**
     * @return {module:echarts/model/Global}
     */
    echartsProto.getModel = function () {
        return this._model;
    };
L
lang 已提交
147

L
tweak  
lang 已提交
148 149 150 151 152 153
    /**
     * @return {number}
     */
    echartsProto.getWidth = function () {
        return this._zr.getWidth();
    };
L
lang 已提交
154

L
tweak  
lang 已提交
155 156 157 158 159 160
    /**
     * @return {number}
     */
    echartsProto.getHeight = function () {
        return this._zr.getHeight();
    };
L
lang 已提交
161

L
tweak  
lang 已提交
162 163 164 165 166
    /**
     * @param {Object} payload
     */
    echartsProto.update = function (payload) {
        console.time && console.time('update');
167

L
tweak  
lang 已提交
168
        var ecModel = this._model;
L
lang 已提交
169

L
tweak  
lang 已提交
170
        ecModel.restoreData();
L
lang 已提交
171

L
tweak  
lang 已提交
172 173 174
        // TODO
        // Save total ecModel here for undo/redo (after restoring data and before processing data).
        // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
P
pah100 已提交
175

L
tweak  
lang 已提交
176
        this._processData(ecModel);
L
lang 已提交
177

L
tweak  
lang 已提交
178
        this._stackSeriesData(ecModel);
L
lang 已提交
179

L
tweak  
lang 已提交
180
        this._coordinateSystem.update(ecModel, this._extensionAPI);
L
lang 已提交
181

L
tweak  
lang 已提交
182
        this._doLayout(ecModel, payload);
183

L
tweak  
lang 已提交
184
        this._doVisualCoding(ecModel, payload);
185

L
tweak  
lang 已提交
186
        this._doRender(ecModel, payload);
187

L
tweak  
lang 已提交
188 189 190 191 192 193 194 195
        // Set background
        var backgroundColor = ecModel.get('backgroundColor');
        // In IE8
        if (!env.canvasSupported) {
            var colorArr = colorTool.parse(backgroundColor);
            backgroundColor = colorTool.stringify(colorArr, 'rgb');
            if (colorArr[3] === 0) {
                backgroundColor = 'transparent';
L
lang 已提交
196
            }
L
tweak  
lang 已提交
197 198
        }
        backgroundColor && (this._dom.style.backgroundColor = backgroundColor);
L
lang 已提交
199

L
tweak  
lang 已提交
200 201
        console.time && console.timeEnd('update');
    };
202

L
tweak  
lang 已提交
203 204 205 206 207 208
    // PENDING
    /**
     * @param {Object} payload
     */
    echartsProto.updateView = function (payload) {
        var ecModel = this._model;
209

L
tweak  
lang 已提交
210
        this._doLayout(ecModel, payload);
211

L
tweak  
lang 已提交
212
        this._doVisualCoding(ecModel, payload);
213

L
tweak  
lang 已提交
214 215
        this._invokeUpdateMethod('updateView', ecModel, payload);
    };
216

L
tweak  
lang 已提交
217 218 219 220 221
    /**
     * @param {Object} payload
     */
    echartsProto.updateVisual = function (payload) {
        var ecModel = this._model;
222

L
tweak  
lang 已提交
223
        this._doVisualCoding(ecModel, payload);
224

L
tweak  
lang 已提交
225 226
        this._invokeUpdateMethod('updateVisual', ecModel, payload);
    };
227

L
tweak  
lang 已提交
228 229 230 231 232
    /**
     * @param {Object} payload
     */
    echartsProto.updateLayout = function (payload) {
        var ecModel = this._model;
233

L
tweak  
lang 已提交
234
        this._doLayout(ecModel, payload);
235

L
tweak  
lang 已提交
236 237
        this._invokeUpdateMethod('updateLayout', ecModel, payload);
    };
L
lang 已提交
238

L
tweak  
lang 已提交
239 240
    echartsProto.resize = function () {
        // var ecModel = this._model;
L
lang 已提交
241

L
tweak  
lang 已提交
242
        // this._coordinateSystem.resize(ecModel, this._extensionAPI);
L
lang 已提交
243

L
tweak  
lang 已提交
244
        // this._doVisualCoding(ecModel);
L
lang 已提交
245

L
tweak  
lang 已提交
246
        // this._doLayout(ecModel);
L
lang 已提交
247

L
tweak  
lang 已提交
248
        // this._doRender(ecModel);
L
lang 已提交
249

L
tweak  
lang 已提交
250 251
        this.update();
    };
P
pah100 已提交
252

L
tweak  
lang 已提交
253 254 255 256 257 258 259 260 261 262 263 264 265 266
    /**
     * @pubilc
     * @param {Object} payload
     * @param {string} [payload.type] Action type
     * @param {number} [payload.from] From uid
     */
    echartsProto.dispatch = function (payload) {
        var actionWrap = actions[payload.type];
        if (actionWrap) {
            var updateMethod = actionWrap.actionInfo.update || 'update';
            actionWrap.action(payload, this._model);
            updateMethod !== 'none' && this[updateMethod](payload);
        }
    };
267

L
tweak  
lang 已提交
268 269 270 271 272 273
    /**
     * @param {string} methodName
     * @private
     */
    echartsProto._invokeUpdateMethod = function (methodName, ecModel, payload) {
        var api = this._extensionAPI;
L
lang 已提交
274

L
tweak  
lang 已提交
275 276 277 278
        // Update all components
        each(this._componentsList, function (component) {
            var componentModel = component.__model;
            component[methodName](componentModel, ecModel, api, payload);
279

L
tweak  
lang 已提交
280 281
            updateZ(componentModel, component);
        }, this);
L
lang 已提交
282

L
tweak  
lang 已提交
283 284 285 286 287
        // Upate all charts
        ecModel.eachSeries(function (seriesModel, idx) {
            var id = getViewId(seriesModel);
            var chart = this._chartsMap[id];
            chart[methodName](seriesModel, ecModel, api, payload);
288

L
tweak  
lang 已提交
289 290
            updateZ(seriesModel, chart);
        }, this);
291

L
tweak  
lang 已提交
292
    };
L
lang 已提交
293

L
tweak  
lang 已提交
294
    echartsProto._prepareCharts = function (ecModel) {
L
lang 已提交
295

L
tweak  
lang 已提交
296 297 298
        var chartsList = this._chartsList;
        var chartsMap = this._chartsMap;
        var zr = this._zr;
L
lang 已提交
299

L
tweak  
lang 已提交
300 301 302
        for (var i = 0; i < chartsList.length; i++) {
            chartsList[i].__keepAlive = false;
        }
L
lang 已提交
303

L
tweak  
lang 已提交
304 305 306 307 308 309 310 311 312 313 314 315 316 317
        ecModel.eachSeries(function (seriesModel, idx) {
            var id = getViewId(seriesModel);

            var chart = chartsMap[id];
            if (!chart) {
                var Clazz = ChartView.getClass(
                    ComponentModel.parseComponentType(seriesModel.type).sub
                );
                if (Clazz) {
                    chart = new Clazz();
                    chart.init(ecModel, this._extensionAPI);
                    chartsMap[id] = chart;
                    chartsList.push(chart);
                    zr.add(chart.group);
L
lang 已提交
318 319
                }
                else {
L
tweak  
lang 已提交
320
                    // Error
L
lang 已提交
321
                }
322
            }
L
lang 已提交
323

L
tweak  
lang 已提交
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
            chart.__keepAlive = true;
            chart.__id = id;
        }, this);

        for (var i = 0; i < chartsList.length;) {
            var chart = chartsList[i];
            if (!chart.__keepAlive) {
                zr.remove(chart.group);
                chart.dispose(this._extensionAPI);
                chartsList.splice(i, 1);
                delete chartsMap[chart.__id];
            }
            else {
                i++;
            }
        }
    };
L
lang 已提交
341

L
tweak  
lang 已提交
342
    echartsProto._prepareComponents = function (ecModel) {
L
lang 已提交
343

L
tweak  
lang 已提交
344 345
        var componentsMap = this._componentsMap;
        var componentsList = this._componentsList;
L
lang 已提交
346

L
tweak  
lang 已提交
347 348 349
        for (var i = 0; i < componentsList.length; i++) {
            componentsList[i].__keepAlive = true;
        }
350

L
tweak  
lang 已提交
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
        ecModel.eachComponent(function (componentType, componentModel) {
            if (componentType === 'series') {
                return;
            }

            var id = getViewId(componentModel);
            var component = componentsMap[id];
            if (!component) {
                // Create and add component
                var Clazz = ComponentView.getClass(
                    componentType, componentModel.option.type
                );

                if (Clazz) {
                    component = new Clazz();
                    component.init(ecModel, this._extensionAPI);
                    componentsMap[id] = component;
                    componentsList.push(component);

                    this._zr.add(component.group);
L
lang 已提交
371
                }
372
            }
L
tweak  
lang 已提交
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
            component.__id = id;
            component.__keepAlive = true;
            // Used in rendering
            component.__model = componentModel;
        }, this);

        for (var i = 0; i < componentsList.length;) {
            var component = componentsList[i];
            if (!component.__keepAlive) {
                this._zr.remove(component.group);
                component.dispose(this._extensionAPI);
                componentsList.splice(i, 1);
                delete componentsMap[component.__id];
            }
            else {
                i++;
            }
        }
    };
L
lang 已提交
392

L
tweak  
lang 已提交
393 394 395 396 397 398 399 400 401 402
    /**
     * Processor data in each series
     *
     * @param {module:echarts/model/Global} ecModel
     * @private
     */
    echartsProto._processData = function (ecModel) {
        each(PROCESSOR_STAGES, function (stage) {
            each(dataProcessorFuncs[stage] || [], function (process) {
                process(ecModel);
L
lang 已提交
403
            });
L
tweak  
lang 已提交
404 405
        });
    };
L
lang 已提交
406

L
tweak  
lang 已提交
407 408 409 410 411 412 413 414 415 416 417 418
    /**
     * @private
     */
    echartsProto._stackSeriesData = function (ecModel) {
        var stackedDataMap = {};
        ecModel.eachSeries(function (series) {
            var stack = series.get('stack');
            var data = series.getData();
            if (stack && data.type === 'list') {
                var previousStack = stackedDataMap[stack];
                if (previousStack) {
                    data.stackedOn = previousStack;
L
lang 已提交
419
                }
L
tweak  
lang 已提交
420 421 422 423
                stackedDataMap[stack] = data;
            }
        });
    };
L
lang 已提交
424

L
tweak  
lang 已提交
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
    /**
     * Layout before each chart render there series after visual coding and data processing
     *
     * @param {module:echarts/model/Global} ecModel
     * @private
     */
    echartsProto._doLayout = function (ecModel, payload) {
        var api = this._extensionAPI;
        each(this._layouts, function (layout) {
            layout.update(ecModel, api, payload);
        });
        each(layoutFuncs, function (layout) {
            layout(ecModel, api, payload);
        });
    };
L
lang 已提交
440

L
tweak  
lang 已提交
441 442 443 444 445 446 447 448 449 450
    /**
     * Code visual infomation from data after data processing
     *
     * @param {module:echarts/model/Global} ecModel
     * @private
     */
    echartsProto._doVisualCoding = function (ecModel, payload) {
        each(VISUAL_CODING_STAGES, function (stage) {
            each(visualCodingFuncs[stage] || [], function (visualCoding) {
                visualCoding(ecModel, payload);
L
lang 已提交
451
            });
L
tweak  
lang 已提交
452 453
        });
    };
L
lang 已提交
454

L
tweak  
lang 已提交
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
    /**
     * Render each chart and component
     * @private
     */
    echartsProto._doRender = function (ecModel, payload) {
        var api = this._extensionAPI;
        // Render all components
        each(this._componentsList, function (component) {
            var componentModel = component.__model;
            component.render(componentModel, ecModel, api, payload);

            updateZ(componentModel, component);
        }, this);

        each(this._chartsList, function (chart) {
            chart.__keepAlive = false;
        }, this);

        // Render all charts
        ecModel.eachSeries(function (seriesModel, idx) {
            var id = getViewId(seriesModel);
            var chart = this._chartsMap[id];
            chart.__keepAlive = true;
            chart.render(seriesModel, ecModel, api, payload);

            updateZ(seriesModel, chart);
        }, this);

        // Remove groups of charts
        each(this._chartsList, function (chart) {
            if (!chart.__keepAlive) {
                chart.remove(ecModel, api);
            }
        }, this);
    };
L
lang 已提交
490

L
tweak  
lang 已提交
491 492 493 494 495 496 497
    echartsProto.dispose = function () {
        each(this._components, function (component) {
            component.dispose();
        });
        each(this._charts, function (chart) {
            chart.dispose();
        });
L
lang 已提交
498

L
tweak  
lang 已提交
499
        this.zr.dispose();
L
lang 已提交
500 501
    };

L
lang 已提交
502 503 504 505 506 507 508 509
    /**
     * @param {module:echarts/model/Series|module:echarts/model/Component} model
     * @return {string}
     */
    function getViewId(model) {
        return model.name + '_' + model.type;
    }

L
lang 已提交
510 511 512 513 514 515 516 517 518 519 520 521 522 523
    /**
     * @param {module:echarts/model/Series|module:echarts/model/Component} model
     * @param {module:echarts/view/Component|module:echarts/view/Chart} view
     * @return {string}
     */
    function updateZ(model, view) {
        var z = model.get('z');
        var zlevel = model.get('zlevel');
        // Set z and zlevel
        view.group.traverse(function (el) {
            z != null && (el.z = z);
            zlevel != null && (el.zlevel = zlevel);
        });
    }
L
lang 已提交
524 525 526 527
    /**
     * @type {Array.<Function>}
     * @inner
     */
P
pah100 已提交
528 529
    var actions = [];

L
lang 已提交
530 531 532 533
    /**
     * @type {Array.<Function>}
     * @inner
     */
L
lang 已提交
534 535
    var layoutClasses = [];

L
lang 已提交
536 537 538 539
    /**
     * @type {Array.<Function>}
     * @inner
     */
540 541
    var layoutFuncs = [];

L
lang 已提交
542 543 544 545 546 547 548
    /**
     * Data processor functions of each stage
     * @type {Array.<Object.<string, Function>>}
     * @inner
     */
    var dataProcessorFuncs = {};

549 550 551 552 553 554
    /**
     * @type {Array.<Function>}
     * @inner
     */
    var optionPreprocessorFuncs = [];

L
lang 已提交
555 556 557 558 559
    /**
     * Visual coding functions of each stage
     * @type {Array.<Object.<string, Function>>}
     * @inner
     */
560
    var visualCodingFuncs = {};
L
lang 已提交
561

L
lang 已提交
562 563 564
    /**
     * @module echarts
     */
L
tweak  
lang 已提交
565
    var echarts = {};
L
lang 已提交
566

L
tweak  
lang 已提交
567 568 569 570 571 572 573 574
    /**
     * @param {HTMLDomElement} dom
     * @param {Object} [theme]
     * @param {Object} opts
     */
    echarts.init = function (dom, theme, opts) {
        return new ECharts(dom, theme, opts);
    };
L
lang 已提交
575

L
tweak  
lang 已提交
576 577 578 579 580 581 582
    /**
     * Register option preprocessor
     * @param {Function} preprocessorFunc
     */
    echarts.registerPreprocessor = function (preprocessorFunc) {
        optionPreprocessorFuncs.push(preprocessorFunc);
    };
583

L
tweak  
lang 已提交
584 585 586 587 588 589 590 591 592 593 594
    /**
     * @param {string} stage
     * @param {Function} processorFunc
     */
    echarts.registerProcessor = function (stage, processorFunc) {
        if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) {
            throw new Error('stage should be one of ' + PROCESSOR_STAGES);
        }
        var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []);
        funcs.push(processorFunc);
    };
L
lang 已提交
595

L
tweak  
lang 已提交
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
    /**
     * Usage:
     * registerAction('someAction', 'someEvent', function () { ... });
     * registerAction('someAction', function () { ... });
     * registerAction(
     *     {type: 'someAction', event: 'someEvent', update: 'updateView'},
     *     function () { ... }
     * );
     *
     * @param {(string|Object)} actionInfo
     * @param {string} actionInfo.type
     * @param {string=} actionInfo.event
     * @param {string=} actionInfo.update
     * @param {Function=} action
     */
    echarts.registerAction = function (actionInfo, action) {
        var actionType = zrUtil.isObject(actionInfo)
            ? actionInfo.type
            : ([actionInfo, actionInfo = {}][0]);
615

L
tweak  
lang 已提交
616 617 618
        if (!actions[actionType]) {
            actions[actionType] = {action: action, actionInfo: actionInfo};
        }
619

L
tweak  
lang 已提交
620 621 622
        // TODO
        // event
    };
P
pah100 已提交
623

L
tweak  
lang 已提交
624 625 626 627 628 629 630
    /**
     * @param {string} type
     * @param {*} CoordinateSystem
     */
    echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
        CoordinateSystemManager.register(type, CoordinateSystem);
    };
L
lang 已提交
631

L
tweak  
lang 已提交
632 633 634 635 636 637 638 639
    /**
     * @param {*} layout
     */
    echarts.registerLayout = function (layout, isFactory) {
        // PENDING All functions ?
        if (isFactory) {
            if (zrUtil.indexOf(layoutClasses, layout) < 0) {
                layoutClasses.push(layout);
640
            }
L
tweak  
lang 已提交
641 642 643 644
        }
        else {
            if (zrUtil.indexOf(layoutFuncs, layout) < 0) {
                layoutFuncs.push(layout);
L
lang 已提交
645
            }
L
tweak  
lang 已提交
646 647
        }
    };
L
lang 已提交
648

L
tweak  
lang 已提交
649 650 651 652 653 654 655 656 657 658 659
    /**
     * @param {string} stage
     * @param {Function} visualCodingFunc
     */
    echarts.registerVisualCoding = function (stage, visualCodingFunc) {
        if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) {
            throw new Error('stage should be one of ' + VISUAL_CODING_STAGES);
        }
        var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []);
        funcs.push(visualCodingFunc);
    };
L
Update  
lang 已提交
660

L
tweak  
lang 已提交
661 662 663 664 665 666
    /**
     * @param
     */
    echarts.registerScale = function (scale) {
        scaleClasses.register(scale);
    };
L
lang 已提交
667

L
tweak  
lang 已提交
668 669 670 671 672 673
    /**
     * @param {Object} opts
     */
    echarts.extendChartView = function (opts) {
        return ChartView.extend(opts);
    };
L
Update  
lang 已提交
674

L
tweak  
lang 已提交
675 676 677 678 679 680
    /**
     * @param {Object} opts
     */
    echarts.extendComponentModel = function (opts) {
        return ComponentModel.extend(opts);
    };
L
Update  
lang 已提交
681

L
tweak  
lang 已提交
682 683 684 685 686 687
    /**
     * @param {Object} opts
     */
    echarts.extendSeriesModel = function (opts) {
        return SeriesModel.extend(opts);
    };
P
pah100 已提交
688

L
tweak  
lang 已提交
689 690 691 692 693
    /**
     * @param {Object} opts
     */
    echarts.extendComponentView = function (opts) {
        return ComponentView.extend(opts);
L
lang 已提交
694 695
    };

L
lang 已提交
696
    echarts.registerVisualCoding('echarts', require('./visual/seriesColor'));
L
lang 已提交
697

698 699
    echarts.registerPreprocessor(require('./preprocessor/backwardCompat'));

L
lang 已提交
700 701
    return echarts;
});