PageSourceSearch

https://www.climatebridge.com/template/index/pc/js/echarts.js

js climatebridge.com collected 2026-10-08 07:24:27 UTC 895,274 bytes, 23,202 lines download raw bytes

1/**
2 * ESL (Enterprise Standard Loader)
3 * Copyright 2013 Baidu Inc. All rights reserved.
4 *
5 * @file Browser端标准加载器,符合AMD规范
6 * @author errorrik([email protected])
7 *         Firede([email protected])
8 */
9
10/* jshint ignore:start */
11var define;
12var require;
13var esl;
14/* jshint ignore:end */
15
16/* eslint-disable guard-for-in */
17/* eslint-env amd:false */
18
19(function (global) {
20    // "mod"开头的变量或函数为内部模块管理函数
21    // 为提高压缩率,不使用function或object包装
22
23    /**
24     * 模块容器
25     *
26     * @inner
27     * @type {Object}
28     */
29    var modModules = {};
30
31    // 模块状态枚举量
32    var MODULE_PRE_DEFINED = 1;
33    var MODULE_ANALYZED = 2;
34    var MODULE_PREPARED = 3;
35    var MODULE_DEFINED = 4;
36
37    /**
38     * 自动定义的模块表
39     *
40     * 模块define factory是用到时才执行,但是以下几种情况需要自动马上执行:
41     * 1. require([moduleId], callback)
42     * 2. plugin module and plugin resource: require('plugin!resource')
43     * 3. shim module
44     *
45     * @inner
46     * @type {Object}
47     */
48    var modAutoDefineModules = {};
49
50    /**
51     * 标记模块自动进行定义
52     *
53     * @inner
54     * @param {string} id 模块id
55     */
56    function modFlagAutoDefine(id) {
57        if (!modIs(id, MODULE_DEFINED)) {
58            modAutoDefineModules[id] = 1;
59        }
60    }
61
62    /**
63     * 内建module名称集合
64     *
65     * @inner
66     * @type {Object}
67     */
68    var BUILDIN_MODULE = {
69        require: globalRequire,
70        exports: 1,
71        module: 1
72    };
73
74    /**
75     * 全局require函数
76     *
77     * @inner
78     * @type {Function}
79     */
80    var actualGlobalRequire = createLocalRequire();
81
82    // #begin-ignore
83    /**
84     * 超时提醒定时器
85     *
86     * @inner
87     * @type {number}
88     */
89    var waitTimeout;
90    // #end-ignore
91
92    /* eslint-disable fecs-key-spacing */
93    /* eslint-disable key-spacing */
94    /**
95     * require配置
96     *
97     * @inner
98     * @type {Object}
99     */
100    var requireConf = {
101        baseUrl    : './',
102        paths      : {},
103        config     : {},
104        map        : {},
105        packages   : [],
106        shim       : {},
107        // #begin-ignore
108        waitSeconds: 0,
109        // #end-ignore
110        bundles    : {},
111        urlArgs    : {}
112    };
113    /* eslint-enable key-spacing */
114
115    /**
116     * 加载模块
117     *
118     * @param {string|Array} requireId 模块id或模块id数组,
119     * @param {Function=} callback 加载完成的回调函数
120     * @return {*} requireId为string时返回模块暴露对象
121     */
122    function globalRequire(requireId, callback) {
123        // #begin-ignore
124        // #begin assertNotContainRelativeId
125        // 确定require的模块id不包含相对id。用于global require,提前预防难以跟踪的错误出现
126        var invalidIds = [];
127
128        /**
129         * 监测模块id是否relative id
130         *
131         * @inner
132         * @param {string} id 模块id
133         */
134        function monitor(id) {
135            if (id.indexOf('.') === 0) {
136                invalidIds.push(id);
137            }
138        }
139
140        if (typeof requireId === 'string') {
141            monitor(requireId);
142        }
143        else {
144            each(
145                requireId,
146                function (id) {
147                    monitor(id);
148                }
149            );
150        }
151
152        // 包含相对id时,直接抛出错误
153        if (invalidIds.length > 0) {
154            throw new Error(
155                '[REQUIRE_FATAL]Relative ID is not allowed in global require: '
156                + invalidIds.join(', ')
157            );
158        }
159        // #end assertNotContainRelativeId
160
161        // 超时提醒
162        var timeout = requireConf.waitSeconds;
163        if (timeout && (requireId instanceof Array)) {
164            if (waitTimeout) {
165                clearTimeout(waitTimeout);
166            }
167            waitTimeout = setTimeout(waitTimeoutNotice, timeout * 1000);
168        }
169        // #end-ignore
170
171        return actualGlobalRequire(requireId, callback);
172    }
173
174    /**
175     * 版本号
176     *
177     * @type {string}
178     */
179    globalRequire.version = '2.0.2';
180
181    /**
182     * loader名称
183     *
184     * @type {string}
185     */
186    globalRequire.loader = 'esl';
187
188    /**
189     * 将模块标识转换成相对的url
190     *
191     * @param {string} id 模块标识
192     * @return {string}
193     */
194    globalRequire.toUrl = actualGlobalRequire.toUrl;
195
196    // #begin-ignore
197    /**
198     * 超时提醒函数
199     *
200     * @inner
201     */
202    function waitTimeoutNotice() {
203        var hangModules = [];
204        var missModules = [];
205        var hangModulesMap = {};
206        var missModulesMap = {};
207        var visited = {};
208
209        /**
210         * 检查模块的加载错误
211         *
212         * @inner
213         * @param {string} id 模块id
214         * @param {boolean} hard 是否装载时依赖
215         */
216        function checkError(id, hard) {
217            if (visited[id] || modIs(id, MODULE_DEFINED)) {
218                return;
219            }
220
221            visited[id] = 1;
222
223            if (!modIs(id, MODULE_PREPARED)) {
224                // HACK: 为gzip后体积优化,不做抽取
225                if (!hangModulesMap[id]) {
226                    hangModulesMap[id] = 1;
227                    hangModules.push(id);
228                }
229            }
230
231            var mod = modModules[id];
232            if (!mod) {
233                if (!missModulesMap[id]) {
234                    missModulesMap[id] = 1;
235                    missModules.push(id);
236                }
237            }
238            else if (hard) {
239                if (!hangModulesMap[id]) {
240                    hangModulesMap[id] = 1;
241                    hangModules.push(id);
242                }
243
244                each(
245                    mod.depMs,
246                    function (dep) {
247                        checkError(dep.absId, dep.hard);
248                    }
249                );
250            }
251        }
252
253        for (var id in modAutoDefineModules) {
254            checkError(id, 1);
255        }
256
257        if (hangModules.length || missModules.length) {
258            throw new Error(
259                '[MODULE_TIMEOUT]Hang( '
260                + (hangModules.join(', ') || 'none')
261                + ' ) Miss( '
262                + (missModules.join(', ') || 'none')
263                + ' )'
264            );
265        }
266    }
267    // #end-ignore
268
269    /**
270     * 未预定义的模块集合
271     * 主要存储匿名方式define的模块
272     *
273     * @inner
274     * @type {Array}
275     */
276    var wait4PreDefine = [];
277
278    /**
279     * 完成模块预定义,此时处理的模块是匿名define的模块
280     *
281     * @inner
282     * @param {string} currentId 匿名define的模块的id
283     */
284    function modCompletePreDefine(currentId) {
285        // HACK: 这里在IE下有个性能陷阱,不能使用任何变量。
286        //       否则貌似会形成变量引用和修改的读写锁,导致wait4PreDefine释放困难
287        each(wait4PreDefine, function (mod) {
288            modPreDefine(
289                currentId,
290                mod.deps,
291                mod.factory
292            );
293        });
294
295        wait4PreDefine.length = 0;
296    }
297
298    /**
299     * 定义模块
300     *
301     * @param {string=} id 模块标识
302     * @param {Array=}
302 dependencies 依赖模块列表
303     * @param {Function=} factory 创建模块的工厂方法
304     */
305    function globalDefine(id, dependencies, factory) {
306        // define(factory)
307        // define(dependencies, factory)
308        // define(id, factory)
309        // define(id, dependencies, factory)
310        if (factory == null) {
311            if (dependencies == null) {
312                factory = id;
313                id = null;
314            }
315            else {
316                factory = dependencies;
317                dependencies = null;
318                if (id instanceof Array) {
319                    dependencies = id;
320                    id = null;
321                }
322            }
323        }
324
325        if (factory == null) {
326            return;
327        }
328
329        var opera = window.opera;
330
331        // IE下通过current script的data-require-id获取当前id
332        if (
333            !id
334            && document.attachEvent
335            && (!(opera && opera.toString() === '[object Opera]'))
336        ) {
337            var currentScript = getCurrentScript();
338            id = currentScript && currentScript.getAttribute('data-require-id');
339        }
340
341        if (id) {
342            modPreDefine(id, dependencies, factory);
343        }
344        else {
345            // 纪录到共享变量中,在load或readystatechange中处理
346            // 标准浏览器下,使用匿名define时,将进入这个分支
347            wait4PreDefine[0] = {
348                deps: dependencies,
349                factory: factory
350            };
351        }
352    }
353
354    globalDefine.amd = {};
355
356    /**
357     * 模块配置获取函数
358     *
359     * @inner
360     * @return {Object} 模块配置对象
361     */
362    function moduleConfigGetter() {
363        var conf = requireConf.config[this.id];
364        if (conf && typeof conf === 'object') {
365            return conf;
366        }
367
368        return {};
369    }
370
371    /**
372     * 预定义模块
373     *
374     * @inner
375     * @param {string} id 模块标识
376     * @param {Array.<string>} dependencies 显式声明的依赖模块列表
377     * @param {*} factory 模块定义函数或模块对象
378     */
379    function modPreDefine(id, dependencies, factory) {
380        // 将模块存入容器
381        //
382        // 模块内部信息包括
383        // -----------------------------------
384        // id: module id
385        // depsDec: 模块定义时声明的依赖
386        // deps: 模块依赖,默认为['require', 'exports', 'module']
387        // factory: 初始化函数或对象
388        // factoryDeps: 初始化函数的参数依赖
389        // exports: 模块的实际暴露对象(AMD定义)
390        // config: 用于获取模块配置信息的函数(AMD定义)
391        // state: 模块当前状态
392        // require: local require函数
393        // depMs: 实际依赖的模块集合,数组形式
394        // depMkv: 实际依赖的模块集合,表形式,便于查找
395        // depRs: 实际依赖的资源集合
396        // ------------------------------------
397        if (!modModules[id]) {
398            /* eslint-disable key-spacing */
399            modModules[id] = {
400                id          : id,
401                depsDec     : dependencies,
402                deps        : dependencies || ['require', 'exports', 'module'],
403                factoryDeps : [],
404                factory     : factory,
405                exports     : {},
406                config      : moduleConfigGetter,
407                state       : MODULE_PRE_DEFINED,
408                require     : createLocalRequire(id),
409                depMs       : [],
410                depMkv      : {},
411                depRs       : []
412            };
413            /* eslint-enable key-spacing */
414        }
415    }
416
417    /**
418     * 开始执行模块定义前的准备工作
419     *
420     * 首先,完成对factory中声明依赖的分析提取
421     * 然后,尝试加载"资源加载所需模块"
422     *
423     * 需要先加载模块的原因是:如果模块不存在,无法进行resourceId normalize化
424     *
425     * @inner
426     * @param {string} id 模块id
427     */
428    function modPrepare(id) {
429        var mod = modModules[id];
430        if (!mod || modIs(id, MODULE_ANALYZED)) {
431            return;
432        }
433
434        var deps = mod.deps;
435        var factory = mod.factory;
436        var hardDependsCount = 0;
437
438        // 分析function body中的require
439        // 如果包含显式依赖声明,根据AMD规定和性能考虑,可以不分析factoryBody
440        if (typeof factory === 'function') {
441            hardDependsCount = Math.min(factory.length, deps.length);
442
443            // If the dependencies argument is present, the module loader
444            // SHOULD NOT scan for dependencies within the factory function.
445            !mod.depsDec && factory.toString()
446                .replace(/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, '')
447                .replace(/require\(\s*(['"'])([^'"]+)\1\s*\)/g,
448                    function ($0, $1, depId) {
449                        deps.push(depId);
450                    }
451                );
452        }
453
454        var requireModules = [];
455        var depResources = [];
456        each(deps, function (depId, index) {
457            var idInfo = parseId(depId);
458            var absId = normalize(idInfo.mod, id);
459            var moduleInfo;
460            var resInfo;
461
462            if (absId && !BUILDIN_MODULE[absId]) {
463                // 如果依赖是一个资源,将其信息添加到module.depRs
464                //
465                // module.depRs中的项有可能是重复的。
466                // 在这个阶段,加载resource的module可能还未defined,
467                // 导致此时resource id无法被normalize。
468                //
469                // 比如对a/b/c而言,下面几个resource可能指的是同一个资源:
470                // - js!../name.js
471                // - js!a/name.js
472                // - ../../js!../name.js
473                //
474                // 所以加载资源的module ready时,需要遍历module.depRs进行处理
475                if (idInfo.res) {
476                    resInfo = {
477                        id: depId,
478                        mod: absId,
479                        res: idInfo.res
480                    };
481                    depResources.push(depId);
482                    mod.depRs.push(resInfo);
483                }
484
485                // 对依赖模块的id normalize能保证正确性,在此处进行去重
486                moduleInfo = mod.depMkv[absId];
487                if (!moduleInfo) {
488                    moduleInfo = {
489                        id: idInfo.mod,
490                        absId: absId,
491                        hard: index < hardDependsCount
492                    };
493                    mod.depMs.push(moduleInfo);
494                    mod.depMkv[absId] = moduleInfo;
495                    requireModules.push(absId);
496                }
497            }
498            else {
499                moduleInfo = {absId: absId};
500            }
501
502            // 如果当前正在分析的依赖项是define中声明的,
503            // 则记录到module.factoryDeps中
504            // 在factory invoke前将用于生成invoke arguments
505            if (index < hardDependsCount) {
506                mod.factoryDeps.push(resInfo || moduleInfo);
507            }
508        });
509
510        mod.state = MODULE_ANALYZED;
511        modInitFactoryInvoker(id);
512        nativeAsyncRequire(requireModules);
513        depResources.length && mod.require(
514            depResources,
515            function () {
516                each(mod.depRs, function (res) {
517                    if (!res.absId) {
518                        res.absId = normalize(res.id, id);
519                    }
520                });
521                modAutoDefine();
522            }
523        );
524    }
525
526    /**
527     * 对一些需要自动定义的模块进行自动定义
528     *
529     * @inner
530     */
531    function modAutoDefine() {
532        for (var id in modAutoDefineModules) {
533            modPrepare(id);
534            modUpdatePreparedState(id);
535            modTryInvokeFactory(id);
536        }
537    }
538
539    /**
540     * 更新模块的准备状态
541     *
542     * @inner
543     * @param {string} id 模块id
544     */
545    function modUpdatePreparedState(id) {
546        var visited = {};
547        update(id);
548
549        function update(id) {
550            modPrepare(id);
551            if (!modIs(id, MODULE_ANALYZED)) {
552                return false;
553            }
554            if (modIs(id, MODULE_PREPARED) || visited[id]) {
555                return true;
556            }
557
558            visited[id] = 1;
559            var mod = modModules[id];
560            var prepared = true;
561
562            each(
563                mod.depMs,
564                function (dep) {
565                    return (prepared = update(dep.absId));
566                }
567            );
568
569            // 判断resource是否加载完成。如果resource未加载完成,则认为未准备好
570            /* jshint ignore:start */
571            prepared && each(
572                mod.depRs,
573                function (dep) {
574                    prepared = !!dep.absId;
575                    return prepared;
576                }
577            );
578            /* jshint ignore:end */
579
580            if (prepared) {
581                mod.state = MODULE_PREPARED;
582            }
583
584            return prepared;
585        }
586    }
587
588    /**
589     * 初始化模块定义时所需的factory执行器
590     *
591     * @inner
592     * @param {string} id 模块id
593     */
594    function modInitFactoryInvoker(id) {
595        var mod = modModules[id];
596        var invoking;
597
598        mod.invokeFactory = invokeFactory;
599
600        /**
601         * 初始化模块
602         *
603         * @inner
604         */
605        function invokeFactory() {
606            if (invoking || mod.state !== MODULE_PREPARED) {
607                return;
608            }
609
610            invoking = 1;
611
612            // 拼接factory invoke所需的arguments
613            var factoryReady = 1;
614            each(
615                mod.factoryDeps,
616                function (dep) {
617                    var depId = dep.absId;
618
619                    if (!BUILDIN_MODULE[depId]) {
620                        modTryInvokeFactory(depId);
621                        return (factoryReady = modIs(depId, MODULE_DEFINED));
622                    }
623                }
624            );
625
626            if (factoryReady) {
627                try {
628                    // 调用factory函数初始化module
629                    var factory = mod.factory;
630                    var exports = typeof factory === 'function'
631                        ? factory.apply(global, modGetModulesExports(
632                                mod.factoryDeps,
633                                {
634                                    require: mod.require,
635                                    exports: mod.exports,
636                                    module: mod
637                                }
638                            ))
639                        : factory;
640
641                    if (exports != null) {
642                        mod.exports = exports;
643                    }
644
645                    mod.invokeFactory = null;
646                }
647                catch (ex) {
648                    if (/^\[MODULE_MISS\]"([^"]+)/.test(ex.message)) {
649                        // 出错,则说明在factory的运行中,该require的模块是需要的
650                        // 所以把它加入强依赖中
651                        var hardCirclurDep = mod.depMkv[RegExp.$1];
652                        hardCirclurDep && (hardCirclurDep.hard = 1);
653                        
654                        // 如果是模块本身有问题导致的运行错误
655                        // 就不要把invoking置回去了,避免影响autoInvoke其他模块的初始化
656                        invoking = 0;
657                        return;
658                    }
659
660                    throw ex;
661                }
662
663                // 完成define
664                // 不放在try里,避免后续的运行错误被这里吞掉
665                modDefined(id);
666            }
667        }
668    }
669
670    /**
671     * 判断模块是否完成相应的状态
672     *
673     * @inner
674     * @param {string} id 模块标识
675     * @param {number} state 状态码,使用时传入相应的枚举变量,比如`MODULE_DEFINED`
676     * @return {boolean} 是否完成相应的状态
677     */
678    function modIs(id, state) {
679        return modModules[id] && modModules[id].state >= state;
680    }
681
682    /**
683     * 尝试执行模块factory函数,进行模块初始化
684     *
685     * @inner
686     * @param {string} id 模块id
687     */
688    function modTryInvokeFactory(id) {
689        var mod = modModules[id];
690
691        if (mod && mod.invokeFactory) {
692            mod.invokeFactory();
693        }
694    }
695
696    /**
697     * 根据模块id数组,获取其的exports数组
698     * 用于模块初始化的factory参数或require的callback参数生成
699     *
700     * @inner
701     * @param {Array} modules 模块id数组
702     * @param {Object} buildinModules 内建模块对象
703     * @return {Array} 模块exports数组
704     */
705    function modGetModulesExports(modules, buildinModules) {
706        var args = [];
707        each(
708            modules,
709            function (id, index) {
710                if (typeof id === 'object') {
711                    id = id.absId;
712                }
713                args[index] = buildinModules[id] || modModules[id].exports;
714            }
715        );
716
717        return args;
718    }
719
720    /**
721     * 模块定义完成事件监听器容器
722     *
723     * @inner
724     * @type {Object}
725     */
726    var modDefinedListeners = {};
727
728    /**
729     * 添加模块定义完成时间的监听器
730     *
731     * @inner
732     * @param {string} id 模块标识
733     * @param {Function} listener 监听函数
734     */
735    function modAddDefinedListener(id, listener) {
736        if (modIs(id, MODULE_DEFINED)) {
737            listener();
738            return;
739        }
740
741        var listeners = modDefinedListeners[id];
742        if (!listeners) {
743            listeners = modDefinedListeners[id] = [];
744        }
745
746        listeners.push(listener);
747    }
748
749    /**
750     * 模块状态切换为定义完成
751     * 因为需要触发事件,MODULE_DEFINED状态切换通过该函数
752     *
753     * @inner
754     * @param {string} id 模块标识
755     */
756    function modDefined(id) {
757        var mod = modModules[id];
758        mod.state = MODULE_DEFINED;
759        delete modAutoDefineModules[id];
760        
761        var listeners = modDefinedListeners[id] || [];
762        var len = listeners.length;
763        while (len--) {
764            // 这里不做function类型的检测
765            // 因为listener都是通过modOn传入的,modOn为内部调用
766            listeners[len]();
767        }
768
769        // 清理listeners
770        listeners.length = 0;
771        modDefinedListeners[id] = null;
772    }
773
774    /**
775     * 异步加载模块
776     * 内部使用,模块ID必须是经过normalize的Top-Level ID
777     *
778     * @inner
779     * @param {Array} ids 模块名称或模块名称列表
780     * @param {Function=} callback 获取模块完成时的回调函数
781     * @param {string} baseId 基础id,用于当ids是relative id时的normalize
782     */
783    function nativeAsyncRequire(ids, callback, baseId) {
784        var isCallbackCalled = 0;
785
786        each(ids, function (id) {
787            if (!(BUILDIN_MODULE[id] || modIs(id, MODULE_DEFINED))) {
788                modAddDefinedListener(id, tryFinishRequire);
789                (id.indexOf('!') > 0
790                    ? loadResource
791                    : loadModule
792                )(id, baseId);
793            }
794        });
795        tryFinishRequire();
796
797        /**
798         * 尝试完成require,调用callback
799         * 在模块与其依赖模块都加载完时调用
800         *
801         * @inner
802         */
803        function tryFinishRequire() {
804            if (typeof callback === 'function' && !isCallbackCalled) {
805                var isAllCompleted = 1;
806                each(ids, function (id) {
807                    if (!BUILDIN_MODULE[id]) {
808                        return (isAllCompleted = !!modIs(id, MODULE_DEFINED));
809                    }
810                });
811
812                // 检测并调用callback
813                if (isAllCompleted) {
814                    isCallbackCalled = 1;
815
816                    callback.apply(
817                        global,
818                        modGetModulesExports(ids, BUILDIN_MODULE)
819                    );
820                }
821            }
822        }
823    }
824
825    /**
826     * 正在加载的模块列表
827     *
828     * @inner
829     * @type {Object}
830     */
831    var loadingModules = {};
832
833    /**
834     * 加载模块
835     *
836     * @inner
837     * @param {string} moduleId 模块标识
838     */
839    function loadModule(moduleId) {
840        // 加载过的模块,就不要再继续了
841        if (loadingModules[moduleId] || modModules[moduleId]) {
842            return;
843        }
844        loadingModules[moduleId] = 1;
845
846        // 初始化相关 shim 的配置
847        var shimConf = requireConf.shim[moduleId];
848        if (shimConf instanceof Array) {
849            requireConf.shim[moduleId] = shimConf = {
850                deps: shimConf
851            };
852        }
853
854        // shim依赖的模块需要自动标识为shim
855        // 无论是纯正的shim模块还是hybird模块
856        var shimDeps = shimConf && (shimConf.deps || []);
857        if (shimDeps) {
858            each(shimDeps, function (dep) {
859                if (!requireConf.shim[dep]) {
860                    requireConf.shim[dep] = {};
861                }
862            });
863            actualGlobalRequire(shimDeps, load);
864        }
865        else {
866            load();
867        }
868
869        /**
870         * 发送请求去加载模块
871         *
872         * @inner
873         */
874        function load() {
875            /* eslint-disable no-use-before-define */
876            var bundleModuleId = bundlesIndex[moduleId];
877            createScript(bundleModuleId || moduleId, loaded);
878            /* eslint-enable no-use-before-define */
879        }
880
881        /**
882         * script标签加载完成的事件处理函数
883         *
884         * @inner
885         */
886        function loaded() {
887            if (shimConf) {
888                var exports;
889                if (typeof shimConf.init === 'function') {
890                    exports = shimConf.init.apply(
891                        global,
892                        modGetModulesExports(shimDeps, BUILDIN_MODULE)
893                    );
894                }
895
896                if (exports == null && shimConf.exports) {
897                    exports = global;
898                    each(
899                        shimConf.exports.split('.'),
900                        function (prop) {
901                            exports = exports[prop];
902                            return !!exports;
903                        }
904                    );
905                }
906
907                globalDefine(moduleId, shimDeps, exports || {});
908            }
909            else {
910                modCompletePreDefine(moduleId);
911            }
912
913            modAutoDefine();
914        }
915    }
916
917    /**
918     * 加载资源
919     *
920     * @inner
921     * @param {string} pluginAndResource 插件与资源标识
922     * @param {string} baseId 当前环境的模块标识
923     */
924    function loadResource(pluginAndResource, baseId) {
925        if (modModules[pluginAndResource]) {
926            return;
927        }
928
929        /* eslint-disable no-use-before-define */
930        var bundleModuleId = bundlesIndex[pluginAndResource];
931        if (bundleModuleId) {
932            loadModule(bundleModuleId);
933            return;
934        }
935        /* eslint-enable no-use-before-define */
936
937        var idInfo = parseId(pluginAndResource);
938        var resource = {
939            id: pluginAndResource,
940            state: MODULE_ANALYZED
941        };
942        modModules[pluginAndResource] = resource;
943
944        /**
945         * plugin加载完成的回调函数
946         *
947         * @inner
948         * @param {*} value resource的值
949         */
950        function pluginOnload(value) {
951            resource.exports = value || true;
952            modDefined(pluginAndResource);
953        }
954
955        /* jshint ignore:start */
956        /**
957         * 该方法允许plugin使用加载的资源声明模块
958         *
959         * @param {string} id 模块id
960         * @param {string} text 模块声明字符串
961         */
962        pluginOnload.fromText = function (id, text) {
963            new Function(text)();
964            modCompletePreDefine(id);
965        };
966        /* jshint ignore:end */
967
968        /**
969         * 加载资源
970         *
971         * @inner
972         * @param {Object} plugin 用于加载资源的插件模块
973         */
974        function load(plugin) {
975            var pluginRequire = baseId
976                ? modModules[baseId].require
977                : actualGlobalRequire;
978
979            plugin.load(
980                idInfo.res,
981                pluginRequire,
982                pluginOnload,
983                moduleConfigGetter.call({id: pluginAndResource})
984            );
985        }
986
987        load(actualGlobalRequire(idInfo.mod));
988    }
989
990    /**
991     * 配置require
992     *
993     * @param {Object} conf 配置对象
994     */
995    globalRequire.config = function (conf) {
996        if (conf) {
997            for (var key in requireConf) {
998                var newValue = conf[key];
999                var oldValue = requireConf[key];
1000
1001                if (!newValue) {
1002                    continue;
1003                }
1004
1005                if (key === 'urlArgs' && typeof newValue === 'string') {
1006                    requireConf.urlArgs['*'] = newValue;
1007                }
1008                else {
1009                    // 简单的多处配置还是需要支持,所以配置实现为支持二级mix
1010                    if (oldValue instanceof Array) {
1011                        oldValue.push.apply(oldValue, newValue);
1012                    }
1013                    else if (typeof oldValue === 'object') {
1014                        for (var k in newValue) {
1015                            oldValue[k] = newValue[k];
1016                        }
1017                    }
1018                    else {
1019                        requireConf[key] = newValue;
1020                    }
1021                }
1022            }
1023
1024            createConfIndex();
1025        }
1026    };
1027
1028    // 初始化时需要创建配置索引
1029    createConfIndex();
1030
1031    /**
1032     * paths内部索引
1033     *
1034     * @inner
1035     * @type {Array}
1036     */
1037    var pathsIndex;
1038
1039    /**
1040     * packages内部索引
1041     *
1042     * @inner
1043     * @type {Array}
1044     */
1045    var packagesIndex;
1046
1047    /**
1048     * mapping内部索引
1049     *
1050     * @inner
1051     * @type {Array}
1052     */
1053    var mappingIdIndex;
1054
1055    /**
1056     * bundles内部索引
1057     *
1058     * @inner
1059     * @type {Object}
1060     */
1061    var bundlesIndex;
1062
1063    /**
1064     * urlArgs内部索引
1065     *
1066     * @inner
1067     * @type {Array}
1068     */
1069    var urlArgsIndex;
1070
1071    /**
1072     * 将key为module id prefix的Object,生成数组形式的索引,并按照长度和字面排序
1073     *
1074     * @inner
1075     * @param {Object} value 源值
1076     * @param {boolean} allowAsterisk 是否允许*号表示匹配所有
1077     * @return {Array} 索引对象
1078     */
1079    function createKVSortedIndex(value, allowAsterisk) {
1080        var index = kv2List(value, 1, allowAsterisk);
1081        index.sort(descSorterByKOrName);
1082        return index;
1083    }
1084
1085    /**
1086     * 创建配置信息内部索引
1087     *
1088     * @inner
1089     */
1090    function createConfIndex() {
1091        requireConf.baseUrl = requireConf.baseUrl.replace(/\/$/, '') + '/';
1092
1093        // create paths index
1094        pathsIndex = createKVSortedIndex(requireConf.paths);
1095
1096        // create mappingId index
1097        mappingIdIndex = createKVSortedIndex(requireConf.map, 1);
1098        each(
1099            mappingIdIndex,
1100            function (item) {
1101                item.v = createKVSortedIndex(item.v);
1102            }
1103        );
1104
1105        // create packages index
1106        packagesIndex = [];
1107        each(
1108            requireConf.packages,
1109            function (packageConf) {
1110                var pkg = packageConf;
1111                if (typeof packageConf === 'string') {
1112                    pkg = {
1113                        name: packageConf.split('/')[0],
1114                        location: packageConf,
1115                        main: 'main'
1116                    };
1117                }
1118
1119                pkg.location = pkg.location || pkg.name;
1120                pkg.main = (pkg.main || 'main').replace(/\.js$/i, '');
1121                pkg.reg = createPrefixRegexp(pkg.name);
1122                packagesIndex.push(pkg);
1123            }
1124        );
1125        packagesIndex.sort(descSorterByKOrName);
1126
1127        // create urlArgs index
1128        urlArgsIndex = createKVSortedIndex(requireConf.urlArgs, 1);
1129
1130        // create bundles index
1131        bundlesIndex = {};
1132        /* eslint-disable no-use-before-define */
1133        function bundlesIterator(id) {
1134            bundlesIndex[id] = key;
1135        }
1136        /* eslint-enable no-use-before-define */
1137        for (var key in requireConf.bundles) {
1138            each(requireConf.bundles[key], bundlesIterator);
1139        }
1140    }
1141
1142    /**
1143     * 对配置信息的索引进行检索
1144     *
1145     * @inner
1146     * @param {string} value 要检索的值
1147     * @param {Array} index 索引对象
1148     * @param {Function} hitBehavior 索引命中的行为函数
1149     */
1150    function indexRetrieve(value, index, hitBehavior) {
1151        each(index, function (item) {
1152            if (item.reg.test(value)) {
1153                hitBehavior(item.v, item.k, item);
1154                return false;
1155            }
1156        });
1157    }
1158
1159    /**
1160     * 将`模块标识+'.extension'`形式的字符串转换成相对的url
1161     *
1162     * @inner
1163     * @param {string} source 源字符串
1164     * @return {string} url
1165     */
1166    function toUrl(source) {
1167        // 分离 模块标识 和 .extension
1168        var extReg = /(\.[a-z0-9]+)$/i;
1169        var queryReg = /(\?[^#]*)$/;
1170        var extname = '';
1171        var id = source;
1172        var query = '';
1173
1174        if (queryReg.test(source)) {
1175            query = RegExp.$1;
1176            source = source.replace(queryReg, '');
1177        }
1178
1179        if (extReg.test(source)) {
1180            extname = RegExp.$1;
1181            id = source.replace(extReg, '');
1182        }
1183
1184        var url = id;
1185
1186        // paths处理和匹配
1187        var isPathMap;
1188        indexRetrieve(id, pathsIndex, function (value, key) {
1189            url = url.replace(key, value);
1190            isPathMap = 1;
1191        });
1192
1193        // packages处理和匹配
1194        if (!isPathMap) {
1195            indexRetrieve(id, packagesIndex, function (value, key, item) {
1196                url = url.replace(item.name, item.location);
1197            });
1198        }
1199
1200        // 相对路径时,附加baseUrl
1201        if (!/^([a-z]{2,10}:\/)?\//i.test(url)) {
1202            url = requireConf.baseUrl + url;
1203        }
1204
1205        // 附加 .extension 和 query
1206        url += extname + query;
1207
1208        // urlArgs处理和匹配
1209        indexRetrieve(id, urlArgsIndex, function (value) {
1210            url += (url.indexOf('?') > 0 ? '&' : '?') + value;
1211        });
1212
1213        return url;
1214    }
1215
1216    /**
1217     * 创建local require函数
1218     *
1219     * @inner
1220     * @param {number} baseId 当前module id
1221     * @return {Function} local require函数
1222     */
1223    function createLocalRequire(baseId) {
1224        var requiredCache = {};
1225
1226        function req(requireId, callback) {
1227            if (typeof requireId === 'string') {
1228                if (!requiredCache[requireId]) {
1229                    var topLevelId = normalize(requireId, baseId);
1230
1231                    // 根据 https://github.com/amdjs/amdjs-api/wiki/require
1232                    // It MUST throw an error if the module has not
1233                    // already been loaded and evaluated.
1234                    modTryInvokeFactory(topLevelId);
1235                    if (!modIs(topLevelId, MODULE_DEFINED)) {
1236                        throw new Error('[MODULE_MISS]"' + topLevelId + '" is not exists!');
1237                    }
1238
1239                    requiredCache[requireId] = modModules[topLevelId].exports;
1240                }
1241
1242                return requiredCache[requireId];
1243            }
1244            else if (requireId instanceof Array) {
1245                // 分析是否有resource,取出pluginModule先
1246                var pureModules = [];
1247                var normalizedIds = [];
1248
1249                each(
1250                    requireId,
1251                    function (id, i) {
1252                        var idInfo = parseId(id);
1253                        var absId = normalize(idInfo.mod, baseId);
1254                        var resId = idInfo.res;
1255                        var normalizedId = absId;
1256
1257                        if (resId) {
1258                            var trueResId = absId + '!' + resId;
1259                            if (resId.indexOf('.') !== 0 && bundlesIndex[trueResId]) {
1260                                absId = normalizedId = trueResId;
1261                            }
1262                            else {
1263                                normalizedId = null;
1264                            }
1265                        }
1266
1267                        normalizedIds[i] = normalizedId;
1268                        modFlagAutoDefine(absId);
1269                        pureModules.push(absId);
1270                    }
1271                );
1272
1273                // 加载模块
1274                nativeAsyncRequire(
1275                    pureModules,
1276                    function () {
1277                        /* jshint ignore:start */
1278                        each(normalizedIds, function (id, i) {
1279                            if (id == null) {
1280                                id = normalizedIds[i] = normalize(requireId[i], baseId);
1281                                modFlagAutoDefine(id);
1282                            }
1283                        });
1284                        /* jshint ignore:end */
1285
1286                        // modAutoDefine中,factory invoke可能发生错误
1287                        // 从而导致nativeAsyncRequire没有被调用,callback没挂上
1288                        // 所以nativeAsyncRequire要先运行
1289                        nativeAsyncRequire(normalizedIds, callback, baseId);
1290                        modAutoDefine();
1291                    },
1292                    baseId
1293                );
1294                modAutoDefine();
1295            }
1296        }
1297
1298        /**
1299         * 将[module ID] + '.extension'格式的字符串转换成url
1300         *
1301         * @inner
1302         * @param {string} id 符合描述格式的源字符串
1303         * @return {string} url
1304         */
1305        req.toUrl = function (id) {
1306            return toUrl(normalize(id, baseId));
1307        };
1308
1309        return req;
1310    }
1311
1312    /**
1313     * id normalize化
1314     *
1315     * @inner
1316     * @param {string} id 需要normalize的模块标识
1317     * @param {string} baseId 当前环境的模块标识
1318     * @return {string} normalize结果
1319     */
1320    function normalize(id, baseId) {
1321        if (!id) {
1322            return '';
1323        }
1324
1325        baseId = baseId || '';
1326        var idInfo = parseId(id);
1327        if (!idInfo) {
1328            return id;
1329        }
1330
1331        var resourceId = idInfo.res;
1332        var moduleId = relative2absolute(idInfo.mod, baseId);
1333
1334        each(
1335            packagesIndex,
1336            function (packageConf) {
1337                var name = packageConf.name;
1338                if (name === moduleId) {
1339                    moduleId = name + '/' + packageConf.main;
1340                    return false;
1341                }
1342            }
1343        );
1344
1345        // 根据config中的map配置进行module id mapping
1346        indexRetrieve(
1347            baseId,
1348            mappingIdIndex,
1349            function (value) {
1350                indexRetrieve(
1351                    moduleId,
1352                    value,
1353                    function (mdValue, mdKey) {
1354                        moduleId = moduleId.replace(mdKey, mdValue);
1355                    }
1356                );
1357            }
1358        );
1359
1360        if (resourceId) {
1361            var mod = modIs(moduleId, MODULE_DEFINED) && actualGlobalRequire(moduleId);
1362            resourceId = mod && mod.normalize
1363                ? mod.normalize(
1364                    resourceId,
1365                    function (resId) {
1366                        return normalize(resId, baseId);
1367                    }
1368                  )
1369                : normalize(resourceId, baseId);
1370
1371            moduleId += '!' + resourceId;
1372        }
1373
1374        return moduleId;
1375    }
1376
1377    /**
1378     * 相对id转换成绝对id
1379     *
1380     * @inner
1381     * @param {string} id 要转换的相对id
1382     * @param {string} baseId 当前所在环境id
1383     * @return {string} 绝对id
1384     */
1385    function relative2absolute(id, baseId) {
1386        if (id.indexOf('.') === 0) {
1387            var basePath = baseId.split('/');
1388            var namePath = id.split('/');
1389            var baseLen = basePath.length - 1;
1390            var nameLen = namePath.length;
1391            var cutBaseTerms = 0;
1392            var cutNameTerms = 0;
1393
1394            /* eslint-disable block-scoped-var */
1395            pathLoop: for (var i = 0; i < nameLen; i++) {
1396                switch (namePath[i]) {
1397                    case '..':
1398                        if (cutBaseTerms < baseLen) {
1399                            cutBaseTerms++;
1400                            cutNameTerms++;
1401                        }
1402                        else {
1403                            break pathLoop;
1404                        }
1405                        break;
1406                    case '.':
1407                        cutNameTerms++;
1408                        break;
1409                    default:
1410                        break pathLoop;
1411                }
1412            }
1413            /* eslint-enable block-scoped-var */
1414
1415            basePath.length = baseLen - cutBaseTerms;
1416            namePath = namePath.slice(cutNameTerms);
1417
1418            return basePath.concat(namePath).join('/');
1419        }
1420
1421        return id;
1422    }
1423
1424    /**
1425     * 解析id,返回带有module和resource属性的Object
1426     *
1427     * @inner
1428     * @param {string} id 标识
1429     * @return {Object} id解析结果对象
1430     */
1431    function parseId(id) {
1432        var segs = id.split('!');
1433
1434        if (segs[0]) {
1435            return {
1436                mod: segs[0],
1437                res: segs[1]
1438            };
1439        }
1440    }
1441
1442    /**
1443     * 将对象数据转换成数组,数组每项是带有k和v的Object
1444     *
1445     * @inner
1446     * @param {Object} source 对象数据
1447     * @param {boolean} keyMatchable key是否允许被前缀匹配
1448     * @param {boolean} allowAsterisk 是否支持*匹配所有
1449     * @return {Array.<Object>} 对象转换数组
1450     */
1451    function kv2List(source, keyMatchable, allowAsterisk) {
1452        var list = [];
1453        for (var key in source) {
1454            if (source.hasOwnProperty(key)) {
1455                var item = {
1456                    k: key,
1457                    v: source[key]
1458                };
1459                list.push(item);
1460
1461                if (keyMatchable) {
1462                    item.reg = key === '*' && allowAsterisk
1463                        ? /^/
1464                        : createPrefixRegexp(key);
1465                }
1466            }
1467        }
1468
1469        return list;
1470    }
1471
1472    // 感谢requirejs,通过currentlyAddingScript兼容老旧ie
1473    //
1474    // For some cache cases in IE 6-8, the script executes before the end
1475    // of the appendChild execution, so to tie an anonymous define
1476    // call to the module name (which is stored on the node), hold on
1477    // to a reference to this node, but clear after the DOM insertion.
1478    var currentlyAddingScript;
1479    var interactiveScript;
1480
1481    /**
1482     * 获取当前script标签
1483     * 用于ie下define未指定module id时获取id
1484     *
1485     * @inner
1486     * @return {HTMLScriptElement} 当前script标签
1487     */
1488    function getCurrentScript() {
1489        if (currentlyAddingScript) {
1490            return currentlyAddingScript;
1491        }
1492        else if (
1493            interactiveScript
1494            && interactiveScript.readyState === 'interactive'
1495        ) {
1496            return interactiveScript;
1497        }
1498
1499        var scripts = document.getElementsByTagName('script');
1500        var scriptLen = scripts.length;
1501        while (scriptLen--) {
1502            var script = scripts[scriptLen];
1503            if (script.readyState === 'interactive') {
1504                interactiveScript = script;
1505                return script;
1506            }
1507        }
1508    }
1509
1510    var headElement = document.getElementsByTagName('head')[0];
1511    var baseElement = document.getElementsByTagName('base')[0];
1512    if (baseElement) {
1513        headElement = baseElement.parentNode;
1514    }
1515
1516    function createScript(moduleId, onload) {
1517        // 创建script标签
1518        //
1519        // 这里不挂接onerror的错误处理
1520        // 因为高级浏览器在devtool的console面板会报错
1521        // 再throw一个Error多此一举了
1522        var script = document.createElement('script');
1523        script.setAttribute('data-require-id', moduleId);
1524        script.src = toUrl(moduleId + '.js');
1525        script.async = true;
1526        if (script.readyState) {
1527            script.onreadystatechange = innerOnload;
1528        }
1529        else {
1530            script.onload = innerOnload;
1531        }
1532
1533        function innerOnload() {
1534            var readyState = script.readyState;
1535            if (
1536                typeof readyState === 'undefined'
1537                || /^(loaded|complete)$/.test(readyState)
1538            ) {
1539                script.onload = script.onreadystatechange = null;
1540                script = null;
1541
1542                onload();
1543            }
1544        }
1545        currentlyAddingScript = script;
1546
1547        // If BASE tag is in play, using appendChild is a problem for IE6.
1548        // See: http://dev.jquery.com/ticket/2709
1549        baseElement
1550            ? headElement.insertBefore(script, baseElement)
1551            : headElement.appendChild(script);
1552
1553        currentlyAddingScript = null;
1554    }
1555
1556    /**
1557     * 创建id前缀匹配的正则对象
1558     *
1559     * @inner
1560     * @param {string} prefix id前缀
1561     * @return {RegExp} 前缀匹配的正则对象
1562     */
1563    function createPrefixRegexp(prefix) {
1564        return new RegExp('^' + prefix + '(/|$)');
1565    }
1566
1567    /**
1568     * 循环遍历数组集合
1569     *
1570     * @inner
1571     * @param {Array} source 数组源
1572     * @param {function(Array,Number):boolean} iterator 遍历函数
1573     */
1574    function each(source, iterator) {
1575        if (source instanceof Array) {
1576            for (var i = 0, len = source.length; i < len; i++) {
1577                if (iterator(source[i], i) === false) {
1578                    break;
1579                }
1580            }
1581        }
1582    }
1583
1584    /**
1585     * 根据元素的k或name项进行数组字符数逆序的排序函数
1586     *
1587     * @inner
1588     * @param {Object} a 要比较的对象a
1589     * @param {Object} b 要比较的对象b
1590     * @return {number} 比较结果
1591     */
1592    function descSorterByKOrName(a, b) {
1593        var aValue = a.k || a.name;
1594        var bValue = b.k || b.name;
1595
1596        if (bValue === '*') {
1597            return -1;
1598        }
1599
1600        if (aValue === '*') {
1601            return 1;
1602        }
1603
1604        return bValue.length - aValue.length;
1605    }
1606
1607    // 暴露全局对象
1608    if (!define) {
1609        define = globalDefine;
1610
1611        // 可能碰到其他形式的loader,所以,不要覆盖人家
1612        if (!require) {
1613            require = globalRequire;
1614        }
1615
1616        // 如果存在其他版本的esl,在define那里就判断过了,不会进入这个分支
1617        // 所以这里就不判断了,直接写
1618        esl = globalRequire;
1619    }
1620})(this);
1621define('echarts', ['echarts/echarts'], function (main) {return main;});
1622define('echarts/echarts', [
1623    'require',
1624    './config',
1625    'zrender/tool/util',
1626    'zrender/tool/event',
1627    'zrender/tool/env',
1628    'zrender',
1629    'zrender/config',
1630    './chart/island',
1631    './component/toolbox',
1632    './component',
1633    './component/title',
1634    './component/tooltip',
1635    './component/legend',
1636    './util/ecData',
1637    './chart',
1638    'zrender/tool/color',
1639    './component/timeline',
1640    'zrender/shape/Image',
1641    'zrender/loadingEffect/Bar',
1642    'zrender/loadingEffect/Bubble',
1643    'zrender/loadingEffect/DynamicLine',
1644    'zrender/loadingEffect/Ring',
1645    'zrender/loadingEffect/Spin',
1646    'zrender/loadingEffect/Whirling',
1647    './theme/macarons',
1648    './theme/infographic'
1649], function (require) {
1650    var ecConfig = require('./config');
1651    var zrUtil = require('zrender/tool/util');
1652    var zrEvent = require('zrender/tool/event');
1653    var self = {};
1654    var _canvasSupported = require('zrender/tool/env').canvasSupported;
1655    var _idBase = new Date() - 0;
1656    var _instances = {};
1657    var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
1658    self.version = '2.2.7';
1659    self.dependencies = { zrender: '2.1.1' };
1660    self.init = function (dom, theme) {
1661        var zrender = require('zrender');
1662        if (zrender.version.replace('.', '') - 0 < self.dependencies.zrender.replace('.', '') - 0) {
1663            console.error('ZRender ' + zrender.version + ' is too old for ECharts ' + self.version + '. Current version need ZRender ' + self.dependencies.zrender + '+');
1664        }
1665        dom = dom instanceof Array ? dom[0] : dom;
1666        var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
1667        if (!key) {
1668            key = _idBase++;
1669            dom.setAttribute(DOM_ATTRIBUTE_KEY, key);
1670        }
1671        if (_instances[key]) {
1672            _instances[key].dispose();
1673        }
1674        _instances[key] = new Echarts(dom);
1675        _instances[key].id = key;
1676        _instances[key].canvasSupported = _canvasSupported;
1677        _instances[key].setTheme(theme);
1678        return _instances[key];
1679    };
1680    self.getInstanceById = function (key) {
1681        return _instances[key];
1682    };
1683    function MessageCenter() {
1684        zrEvent.Dispatcher.call(this);
1685    }
1686    zrUtil.merge(MessageCenter.prototype, zrEvent.Dispatcher.prototype, true);
1687    function Echarts(dom) {
1688        dom.innerHTML = '';
1689        this._themeConfig = {};
1690        this.dom = dom;
1691        this._connected = false;
1692        this._status = {
1693            dragIn: false,
1694            dragOut: false,
1695            needRefresh: false
1696        };
1697        this._curEventType = false;
1698        this._chartList = [];
1699        this._messageCenter = new MessageCenter();
1700        this._messageCenterOutSide = new MessageCenter();
1701        this.resize = this.resize();
1702        this._init();
1703    }
1704    var ZR_EVENT = require('zrender/config').EVENT;
1705    var ZR_EVENT_LISTENS = [
1706        'CLICK',
1707        'DBLCLICK',
1708        'MOUSEOVER',
1709        'MOUSEOUT',
1710        'DRAGSTART',
1711        'DRAGEND',
1712        'DRAGENTER',
1713        'DRAGOVER',
1714        'DRAGLEAVE',
1715        'DROP'
1716    ];
1717    function callChartListMethodReverse(ecInstance, methodName, arg0, arg1, arg2) {
1718        var chartList = ecInstance._chartList;
1719        var len = chartList.length;
1720        while (len--) {
1721            var chart = chartList[len];
1722            if (typeof chart[methodName] === 'function') {
1723                chart[methodName](arg0, arg1, arg2);
1724            }
1725        }
1726    }
1727    Echarts.prototype = {
1728        _init: function () {
1729            var self = this;
1730            var _zr = require('zrender').init(this.dom);
1731            this._zr = _zr;
1732            this._messageCenter.dispatch = function (type, event, eventPackage, that) {
1733                eventPackage = eventPackage || {};
1734                eventPackage.type = type;
1735                eventPackage.event = event;
1736                self._messageCenter.dispatchWithContext(type, eventPackage, that);
1737                self._messageCenterOutSide.dispatchWithContext(type, eventPackage, that);
1738            };
1739            this._onevent = function (param) {
1740                return self.__onevent(param);
1741            };
1742            for (var e in ecConfig.EVENT) {
1743                if (e != 'CLICK' && e != 'DBLCLICK' && e != 'HOVER' && e != 'MOUSEOUT' && e != 'MAP_ROAM') {
1744                    this._messageCenter.bind(ecConfig.EVENT[e], this._onevent, this);
1745                }
1746            }
1747            var eventBehaviors = {};
1748            this._onzrevent = function (param) {
1749                return self[eventBehaviors[param.type]](param);
1750            };
1751            for (var i = 0, len = ZR_EVENT_LISTENS.length; i < len; i++) {
1752                var eventName = ZR_EVENT_LISTENS[i];
1753                var eventValue = ZR_EVENT[eventName];
1754                eventBehaviors[eventValue] = '_on' + eventName.toLowerCase();
1755                _zr.on(eventValue, this._onzrevent);
1756            }
1757            this.chart = {};
1758            this.component = {};
1759            var Island = require('./chart/island');
1760            this._island = new Island(this._themeConfig, this._messageCenter, _zr, {}, this);
1761            this.chart.island = this._island;
1762            var Toolbox = require('./component/toolbox');
1763            this._toolbox = new Toolbox(this._themeConfig, this._messageCenter, _zr, {}, this);
1764            this.component.toolbox = this._toolbox;
1765            var componentLibrary = require('./component');
1766            componentLibrary.define('title', require('./component/title'));
1767            componentLibrary.define('tooltip', require('./component/tooltip'));
1768            componentLibrary.define('legend', require('./component/legend'));
1769            if (_zr.getWidth() === 0 || _zr.getHeight() === 0) {
1770                console.error('Dom’s width & height should be ready before init.');
1771            }
1772        },
1773        __onevent: function (param) {
1774            param.__echartsId = param.__echartsId || this.id;
1775            var fromMyself = param.__echartsId === this.id;
1776            if (!this._curEventType) {
1777                this._curEventType = param.type;
1778            }
1779            switch (param.type) {
1780            case ecConfig.EVENT.LEGEND_SELECTED:
1781                this._onlegendSelected(param);
1782                break;
1783            case ecConfig.EVENT.DATA_ZOOM:
1784                if (!fromMyself) {
1785                    var dz = this.component.dataZoom;
1786                    if (dz) {
1787                        dz.silence(true);
1788                        dz.absoluteZoom(param.zoom);
1789                        dz.silence(false);
1790                    }
1791                }
1792                this._ondataZoom(param);
1793                break;
1794            case ecConfig.EVENT.DATA_RANGE:
1795                fromMyself && this._ondataRange(param);
1796                break;
1797            case ecConfig.EVENT.MAGIC_TYPE_CHANGED:
1798                if (!fromMyself) {
1799                    var tb = this.component.toolbox;
1800                    if (tb) {
1801                        tb.silence(true);
1802                        tb.setMagicType(param.magicType);
1803                        tb.silence(false);
1804                    }
1805                }
1806                this._onmagicTypeChanged(param);
1807                break;
1808            case ecConfig.EVENT.DATA_VIEW_CHANGED:
1809                fromMyself && this._ondataViewChanged(param);
1810                break;
1811            case ecConfig.EVENT.TOOLTIP_HOVER:
1812                fromMyself && this._tooltipHover(param);
1813                break;
1814            case ecConfig.EVENT.RESTORE:
1815                this._onrestore();
1816                break;
1817            case ecConfig.EVENT.REFRESH:
1818                fromMyself && this._onrefresh(param);
1819                break;
1820            case ecConfig.EVENT.TOOLTIP_IN_GRID:
1821            case ecConfig.EVENT.TOOLTIP_OUT_GRID:
1822                if (!fromMyself) {
1823                    var grid = this.component.grid;
1824                    if (grid) {
1825                        this._zr.trigger('mousemove', {
1826                            connectTrigger: true,
1827                            zrenderX: grid.getX() + param.x * grid.getWidth(),
1828                            zrenderY: grid.getY() + param.y * grid.getHeight()
1829                        });
1830                    }
1831                } else if (this._connected) {
1832                    var grid = this.component.grid;
1833                    if (grid) {
1834                        param.x = (param.event.zrenderX - grid.getX()) / grid.getWidth();
1835                        param.y = (param.event.zrenderY - grid.getY()) / grid.getHeight();
1836                    }
1837                }
1838                break;
1839            }
1840            if (this._connected && fromMyself && this._curEventType === param.type) {
1841                for (var c in this._connected) {
1842                    this._connected[c].connectedEventHandler(param);
1843                }
1844                this._curEventType = null;
1845            }
1846            if (!fromMyself || !this._connected && fromMyself) {
1847                this._curEventType = null;
1848            }
1849        },
1850        _onclick: function (param) {
1851            callChartListMethodReverse(this, 'onclick', param);
1852            if (param.target) {
1853                var ecData = this._eventPackage(param.target);
1854                if (ecData && ecData.seriesIndex != null) {
1855                    this._messageCenter.dispatch(ecConfig.EVENT.CLICK, param.event, ecData, this);
1856                }
1857            }
1858        },
1859        _ondblclick: function (param) {
1860            callChartListMethodReverse(this, 'ondblclick', param);
1861            if (param.target) {
1862                var ecData = this._eventPackage(param.target);
1863                if (ecData && ecData.seriesIndex != null) {
1864                    this._messageCenter.dispatch(ecConfig.EVENT.DBLCLICK, param.event, ecData, this);
1865                }
1866            }
1867        },
1868        _onmouseover: function (param) {
1869            if (param.target) {
1870                var ecData = this._eventPackage(param.target);
1871                if (ecData && ecData.seriesIndex != null) {
1872                    this._messageCenter.dispatch(ecConfig.EVENT.HOVER, param.event, ecData, this);
1873                }
1874            }
1875        },
1876        _onmouseout: function (param) {
1877            if (param.target) {
1878                var ecData = this._eventPackage(param.target);
1879                if (ecData && ecData.seriesIndex != null) {
1880                    this._messageCenter.dispatch(ecConfig.EVENT.MOUSEOUT, param.event, ecData, this);
1881                }
1882            }
1883        },
1884        _ondragstart: function (param) {
1885            this._status = {
1886                dragIn: false,
1887                dragOut: false,
1888                needRefresh: false
1889            };
1890            callChartListMethodReverse(this, 'ondragstart', param);
1891        },
1892        _ondragenter: function (param) {
1893            callChartListMethodReverse(this, 'ondragenter', param);
1894        },
1895        _ondragover: function (param) {
1896            callChartListMethodReverse(this, 'ondragover', param);
1897        },
1898        _ondragleave: function (param) {
1899            callChartListMethodReverse(this, 'ondragleave', param);
1900        },
1901        _ondrop: function (param) {
1902            callChartListMethodReverse(this, 'ondrop', param, this._status);
1903            this._island.ondrop(param, this._status);
1904        },
1905        _ondragend: function (param) {
1906            callChartListMethodReverse(this, 'ondragend', param, this._status);
1907            this._timeline && this._timeline.ondragend(param, this._status);
1908            this._island.ondragend(param, this._status);
1909            if (this._status.needRefresh) {
1910                this._syncBackupData(this._option);
1911                var messageCenter = this._messageCenter;
1912                messageCenter.dispatch(ecConfig.EVENT.DATA_CHANGED, param.event, this._eventPackage(param.target), this);
1913                messageCenter.dispatch(ecConfig.EVENT.REFRESH, null, null, this);
1914            }
1915        },
1916        _onlegendSelected: function (param) {
1917            this._status.needRefresh = false;
1918            callChartListMethodReverse(this, 'onlegendSelected', param, this._status);
1919            if (this._status.needRefresh) {
1920                this._messageCenter.dispatch(ecConfig.EVENT.REFRESH, null, null, this);
1921            }
1922        },
1923        _ondataZoom: function (param) {
1924            this._status.needRefresh = false;
1925            callChartListMethodReverse(this, 'ondataZoom', param, this._status);
1926            if (this._status.needRefresh) {
1927                this._messageCenter.dispatch(ecConfig.EVENT.REFRESH, null, null, this);
1928            }
1929        },
1930        _ondataRange: function (param) {
1931            this._clearEffect();
1932            this._status.needRefresh = false;
1933            callChartListMethodReverse(this, 'ondataRange', param, this._status);
1934            if (this._status.needRefresh) {
1935                this._zr.refreshNextFrame();
1936            }
1937        },
1938        _onmagicTypeChanged: function () {
1939            this._clearEffect();
1940            this._render(this._toolbox.getMagicOption());
1941        },
1942        _ondataViewChanged: function (param) {
1943            this._syncBackupData(param.option);
1944            this._messageCenter.dispatch(ecConfig.EVENT.DATA_CHANGED, null, param, this);
1945            this._messageCenter.dispatch(ecConfig.EVENT.REFRESH, null, null, this);
1946        },
1947        _tooltipHover: function (param) {
1948            var tipShape = [];
1949            callChartListMethodReverse(this, 'ontooltipHover', param, tipShape);
1950        },
1951        _onrestore: function () {
1952            this.restore();
1953        },
1954        _onrefresh: function (param) {
1955            this._refreshInside = true;
1956            this.refresh(param);
1957            this._refreshInside = false;
1958        },
1959        _syncBackupData: function (curOption) {
1960            this.component.dataZoom && this.component.dataZoom.syncBackupData(curOption);
1961        },
1962        _eventPackage: function (target) {
1963            if (target) {
1964                var ecData = require('./util/ecData');
1965                var seriesIndex = ecData.get(target, 'seriesIndex');
1966                var dataIndex = ecData.get(target, 'dataIndex');
1967                dataIndex = seriesIndex != -1 && this.component.dataZoom ? this.component.dataZoom.getRealDataIndex(seriesIndex, dataIndex) : dataIndex;
1968                return {
1969                    seriesIndex: seriesIndex,
1970                    seriesName: (ecData.get(target, 'series') || {}).name,
1971                    dataIndex: dataIndex,
1972                    data: ecData.get(target, 'data'),
1973                    name: ecData.get(target, 'name'),
1974                    value: ecData.get(target, 'value'),
1975                    special: ecData.get(target, 'special')
1976                };
1977            }
1978            return;
1979        },
1980        _noDataCheck: function (magicOption) {
1981            var series = magicOption.series;
1982            for (var i = 0, l = series.length; i < l; i++) {
1983                if (series[i].type == ecConfig.CHART_TYPE_MAP || series[i].data && series[i].data.length > 0 || series[i].markPoint && series[i].markPoint.data && series[i].markPoint.data.length > 0 || series[i].markLine && series[i].markLine.data && series[i].markLine.data.length > 0 || series[i].nodes && series[i].nodes.length > 0 || series[i].links && series[i].links.length > 0 || series[i].matrix && series[i].matrix.length > 0 || series[i].eventList && series[i].eventList.length > 0) {
1984                    return false;
1985                }
1986            }
1987            var loadOption = this._option && this._option.noDataLoadingOption || this._themeConfig.noDataLoadingOption || ecConfig.noDataLoadingOption || {
1988                text: this._option && this._option.noDataText || this._themeConfig.noDataText || ecConfig.noDataText,
1989                effect: this._option && this._option.noDataEffect || this._themeConfig.noDataEffect || ecConfig.noDataEffect
1990            };
1991            this.clear();
1992            this.showLoading(loadOption);
1993            return true;
1994        },
1995        _render: function (magicOption) {
1996            this._mergeGlobalConifg(magicOption);
1997            if (this._noDataCheck(magicOption)) {
1998                return;
1999            }
2000            var bgColor = magicOption.backgroundColor;
2001            if (bgColor) {
2002                if (!_canvasSupported && bgColor.indexOf('rgba') != -1) {
2003                    var cList = bgColor.split(',');
2004                    this.dom.style.filter = 'alpha(opacity=' + cList[3].substring(0, cList[3].lastIndexOf(')')) * 100 + ')';
2005                    cList.length = 3;
2006                    cList[0] = cList[0].replace('a', '');
2007                    this.dom.style.backgroundColor = cList.join(',') + ')';
2008                } else {
2009                    this.dom.style.backgroundColor = bgColor;
2010                }
2011            }
2012            this._zr.clearAnimation();
2013            this._chartList = [];
2014            var chartLibrary = require('./chart');
2015            var componentLibrary = require('./component');
2016            if (magicOption.xAxis || magicOption.yAxis) {
2017                magicOption.grid = magicOption.grid || {};
2018                magicOption.dataZoom = magicOption.dataZoom || {};
2019            }
2020            var componentList = [
2021                'title',
2022                'legend',
2023                'tooltip',
2024                'dataRange',
2025                'roamController',
2026                'grid',
2027                'dataZoom',
2028                'xAxis',
2029                'yAxis',
2030                'polar'
2031            ];
2032            var ComponentClass;
2033            var componentType;
2034            var component;
2035            for (var i = 0, l = componentList.length; i < l; i++) {
2036                componentType = componentList[i];
2037                component = this.component[componentType];
2038                if (magicOption[componentType]) {
2039                    if (component) {
2040                        component.refresh && component.refresh(magicOption);
2041                    } else {
2042                        ComponentClass = componentLibrary.get(/^[xy]Axis$/.test(componentType) ? 'axis' : componentType);
2043                        component = new ComponentClass(this._themeConfig, this._messageCenter, this._zr, magicOption, this, componentType);
2044                        this.component[componentType] = component;
2045                    }
2046                    this._chartList.push(component);
2047                } else if (component) {
2048                    component.dispose();
2049                    this.component[componentType] = null;
2050                    delete this.component[componentType];
2051                }
2052            }
2053            var ChartClass;
2054            var chartType;
2055            var chart;
2056            var chartMap = {};
2057            for (var i = 0, l = magicOption.series.length; i < l; i++) {
2058                chartType = magicOption.series[i].type;
2059                if (!chartType) {
2060                    console.error('series[' + i + '] chart type has not been defined.');
2061                    continue;
2062                }
2063                if (!chartMap[chartType]) {
2064                    chartMap[chartType] = true;
2065                    ChartClass = chartLibrary.get(chartType);
2066                    if (ChartClass) {
2067                        if (this.chart[chartType]) {
2068                            chart = this.chart[chartType];
2069                            chart.refresh(magicOption);
2070                        } else {
2071                            chart = new ChartClass(this._themeConfig, this._messageCenter, this._zr, magicOption, this);
2072                        }
2073                        this._chartList.push(chart);
2074                        this.chart[chartType] = chart;
2075                    } else {
2076                        console.error(chartType + ' has not been required.');
2077                    }
2078                }
2079            }
2080            for (chartType in this.chart) {
2081                if (chartType != ecConfig.CHART_TYPE_ISLAND && !chartMap[chartType]) {
2082                    this.chart[chartType].dispose();
2083                    this.chart[chartType] = null;
2084                    delete this.chart[chartType];
2085                }
2086            }
2087            this.component.grid && this.component.grid.refixAxisShape(this.component);
2088            this._island.refresh(magicOption);
2089            this._toolbox.refresh(magicOption);
2090            magicOption.animation && !magicOption.renderAsImage ? this._zr.refresh() : this._zr.render();
2091            var imgId = 'IMG' + this.id;
2092            var img = document.getElementById(imgId);
2093            if (magicOption.renderAsImage && _canvasSupported) {
2094                if (img) {
2095                    img.src = this.getDataURL(magicOption.renderAsImage);
2096                } else {
2097                    img = this.getImage(magicOption.renderAsImage);
2098                    img.id = imgId;
2099                    img.style.position = 'absolute';
2100                    img.style.left = 0;
2101                    img.style.top = 0;
2102                    this.dom.firstChild.appendChild(img);
2103                }
2104                this.un();
2105                this._zr.un();
2106                this._disposeChartList();
2107                this._zr.clear();
2108            } else if (img) {
2109                img.parentNode.removeChild(img);
2110            }
2111            img = null;
2112            this._option = magicOption;
2113        },
2114        restore: function () {
2115            this._clearEffect();
2116            this._option = zrUtil.clone(this._optionRestore);
2117            this._disposeChartList();
2118            this._island.clear();
2119            this._toolbox.reset(this._option, true);
2120            this._render(this._option);
2121        },
2122        refresh: function (param) {
2123            this._clearEffect();
2124            param = param || {};
2125            var magicOption = param.option;
2126            if (!this._refreshInside && magicOption) {
2127                magicOption = this.getOption();
2128                zrUtil.merge(magicOption, param.option, true);
2129                zrUtil.merge(this._optionRestore, param.option, true);
2130                this._toolbox.reset(magicOption);
2131            }
2132            this._island.refresh(magicOption);
2133            this._toolbox.refresh(magicOption);
2134            this._zr.clearAnimation();
2135            for (var i = 0, l = this._chartList.length; i < l; i++) {
2136                this._chartList[i].refresh && this._chartList[i].refresh(magicOption);
2137            }
2138            this.component.grid && this.component.grid.refixAxisShape(this.component);
2139            this._zr.refresh();
2140        },
2141        _disposeChartList: function () {
2142            this._clearEffect();
2143            this._zr.clearAnimation();
2144            var len = this._chartList.length;
2145            while (len--) {
2146                var chart = this._chartList[len];
2147                if (chart) {
2148                    var chartType = chart.type;
2149                    this.chart[chartType] && delete this.chart[chartType];
2150                    this.component[chartType] && delete this.component[chartType];
2151                    chart.dispose && chart.dispose();
2152                }
2153            }
2154            this._chartList = [];
2155        },
2156        _mergeGlobalConifg: function (magicOption) {
2157            var mergeList = [
2158                'backgroundColor',
2159                'calculable',
2160                'calculableColor',
2161                'calculableHolderColor',
2162                'nameConnector',
2163                'valueConnector',
2164                'animation',
2165                'animationThreshold',
2166                'animationDuration',
2167                'animationDurationUpdate',
2168                'animationEasing',
2169                'addDataAnimation',
2170                'symbolList',
2171                'DRAG_ENABLE_TIME'
2172            ];
2173            var len = mergeList.length;
2174            while (len--) {
2175                var mergeItem = mergeList[len];
2176                if (magicOption[mergeItem] == null) {
2177                    magicOption[mergeItem] = this._themeConfig[mergeItem] != null ? this._themeConfig[mergeItem] : ecConfig[mergeItem];
2178                }
2179            }
2180            var themeColor = magicOption.color;
2181            if (!(themeColor && themeColor.length)) {
2182                themeColor = this._themeConfig.color || ecConfig.color;
2183            }
2184            this._zr.getColor = function (idx) {
2185                var zrColor = require('zrender/tool/color');
2186                return zrColor.getColor(idx, themeColor);
2187            };
2188            if (!_canvasSupported) {
2189                magicOption.animation = false;
2190                magicOption.addDataAnimation = false;
2191            }
2192        },
2193        setOption: function (option, notMerge) {
2194            if (!option.timeline) {
2195                return this._setOption(option, notMerge);
2196            } else {
2197                return this._setTimelineOption(option);
2198            }
2199        },
2200        _setOption: function (option, notMerge, keepTimeLine) {
2201            if (!notMerge && this._option) {
2202                this._option = zrUtil.merge(this.getOption(), zrUtil.clone(option), true);
2203            } else {
2204                this._option = zrUtil.clone(option);
2205                !keepTimeLine && this._timeline && this._timeline.dispose();
2206            }
2207            this._optionRestore = zrUtil.clone(this._option);
2208            if (!this._option.series || this._option.series.length === 0) {
2209                this._zr.clear();
2210                return;
2211            }
2212            if (this.component.dataZoom && (this._option.dataZoom || this._option.toolbox && this._option.toolbox.feature && this._option.toolbox.feature.dataZoom && this._option.toolbox.feature.dataZoom.show)) {
2213                this.component.dataZoom.syncOption(this._option);
2214            }
2215            this._toolbox.reset(this._option);
2216            this._render(this._option);
2217            return this;
2218        },
2219        getOption: function () {
2220            var magicOption = zrUtil.clone(this._option);
2221            var self = this;
2222            function restoreOption(prop) {
2223                var restoreSource = self._optionRestore[prop];
2224                if (restoreSource) {
2225                    if (restoreSource instanceof Array) {
2226                        var len = restoreSource.length;
2227                        while (len--) {
2228                            magicOption[prop][len].data = zrUtil.clone(restoreSource[len].data);
2229                        }
2230                    } else {
2231                        magicOption[prop].data = zrUtil.clone(restoreSource.data);
2232                    }
2233                }
2234            }
2235            restoreOption('xAxis');
2236            restoreOption('yAxis');
2237            restoreOption('series');
2238            return magicOption;
2239        },
2240        setSeries: function (series, notMerge) {
2241            if (!notMerge) {
2242                this.setOption({ series: series });
2243            } else {
2244                this._option.series = series;
2245                this.setOption(this._option, notMerge);
2246            }
2247            return this;
2248        },
2249        getSeries: function () {
2250            return this.getOption().series;
2251        },
2252        _setTimelineOption: function (option) {
2253            this._timeline && this._timeline.dispose();
2254            var Timeline = require('./component/timeline');
2255            var timeline = new Timeline(this._themeConfig, this._messageCenter, this._zr, option, this);
2256            this._timeline = timeline;
2257            this.component.timeline = this._timeline;
2258            return this;
2259        },
2260        addData: function (seriesIdx, data, isHead, dataGrow, additionData) {
2261            var params = seriesIdx instanceof Array ? seriesIdx : [[
2262                    seriesIdx,
2263                    data,
2264                    isHead,
2265                    dataGrow,
2266                    additionData
2267                ]];
2268            var magicOption = this.getOption();
2269            var optionRestore = this._optionRestore;
2270            var self = this;
2271            for (var i = 0, l = params.length; i < l; i++) {
2272                seriesIdx = params[i][0];
2273                data = params[i][1];
2274                isHead = params[i][2];
2275                dataGrow = params[i][3];
2276                additionData = params[i][4];
2277                var seriesItem = optionRestore.series[seriesIdx];
2278                var inMethod = isHead ? 'unshift' : 'push';
2279                var outMethod = isHead ? 'pop' : 'shift';
2280                if (seriesItem) {
2281                    var seriesItemData = seriesItem.data;
2282                    var mSeriesItemData = magicOption.series[seriesIdx].data;
2283                    seriesItemData[inMethod](data);
2284                    mSeriesItemData[inMethod](data);
2285                    if (!dataGrow) {
2286                        seriesItemData[outMethod]();
2287                        data = mSeriesItemData[outMethod]();
2288                    }
2289                    if (additionData != null) {
2290                        var legend;
2291                        var legendData;
2292                        if (seriesItem.type === ecConfig.CHART_TYPE_PIE && (legend = optionRestore.legend) && (legendData = legend.data)) {
2293                            var mLegendData = magicOption.legend.data;
2294                            legendData[inMethod](additionData);
2295                            mLegendData[inMethod](additionData);
2296                            if (!dataGrow) {
2297                                var legendDataIdx = zrUtil.indexOf(legendData, data.name);
2298                                legendDataIdx != -1 && legendData.splice(legendDataIdx, 1);
2299                                legendDataIdx = zrUtil.indexOf(mLegendData, data.name);
2300                                legendDataIdx != -1 && mLegendData.splice(legendDataIdx, 1);
2301                            }
2302                        } else if (optionRestore.xAxis != null && optionRestore.yAxis != null) {
2303                            var axisData;
2304                            var mAxisData;
2305                            var axisIdx = seriesItem.xAxisIndex || 0;
2306                            if (optionRestore.xAxis[axisIdx].type == null || optionRestore.xAxis[axisIdx].type === 'category') {
2307                                axisData = optionRestore.xAxis[axisIdx].data;
2308                                mAxisData = magicOption.xAxis[axisIdx].data;
2309                                axisData[inMethod](additionData);
2310                                mAxisData[inMethod](additionData);
2311                                if (!dataGrow) {
2312                                    axisData[outMethod]();
2313                                    mAxisData[outMethod]();
2314                                }
2315                            }
2316                            axisIdx = seriesItem.yAxisIndex || 0;
2317                            if (optionRestore.yAxis[axisIdx].type === 'category') {
2318                                axisData = optionRestore.yAxis[axisIdx].data;
2319                                mAxisData = magicOption.yAxis[axisIdx].data;
2320                                axisData[inMethod](additionData);
2321                                mAxisData[inMethod](additionData);
2322                                if (!dataGrow) {
2323                                    axisData[outMethod]();
2324                                    mAxisData[outMethod]();
2325                                }
2326                            }
2327                        }
2328                    }
2329                    this._option.series[seriesIdx].data = magicOption.series[seriesIdx].data;
2330                }
2331            }
2332            this._zr.clearAnimation();
2333            var chartList = this._chartList;
2334            var chartAnimationCount = 0;
2335            var chartAnimationDone = function () {
2336                chartAnimationCount--;
2337                if (chartAnimationCount === 0) {
2338                    animationDone();
2339                }
2340            };
2341            for (var i = 0, l = chartList.length; i < l; i++) {
2342                if (magicOption.addDataAnimation && chartList[i].addDataAnimation) {
2343                    chartAnimationCount++;
2344                    chartList[i].addDataAnimation(params, chartAnimationDone);
2345                }
2346            }
2347            this.component.dataZoom && this.component.dataZoom.syncOption(magicOption);
2348            this._option = magicOption;
2349            function animationDone() {
2350                if (!self._zr) {
2351                    return;
2352                }
2353                self._zr.clearAnimation();
2354                for (var i = 0, l = chartList.length; i < l; i++) {
2355                    chartList[i].motionlessOnce = magicOption.addD
2355ataAnimation && chartList[i].addDataAnimation;
2356                }
2357                self._messageCenter.dispatch(ecConfig.EVENT.REFRESH, null, { option: magicOption }, self);
2358            }
2359            if (!magicOption.addDataAnimation) {
2360                setTimeout(animationDone, 0);
2361            }
2362            return this;
2363        },
2364        addMarkPoint: function (seriesIdx, markData) {
2365            return this._addMark(seriesIdx, markData, 'markPoint');
2366        },
2367        addMarkLine: function (seriesIdx, markData) {
2368            return this._addMark(seriesIdx, markData, 'markLine');
2369        },
2370        _addMark: function (seriesIdx, markData, markType) {
2371            var series = this._option.series;
2372            var seriesItem;
2373            if (series && (seriesItem = series[seriesIdx])) {
2374                var seriesR = this._optionRestore.series;
2375                var seriesRItem = seriesR[seriesIdx];
2376                var markOpt = seriesItem[markType];
2377                var markOptR = seriesRItem[markType];
2378                markOpt = seriesItem[markType] = markOpt || { data: [] };
2379                markOptR = seriesRItem[markType] = markOptR || { data: [] };
2380                for (var key in markData) {
2381                    if (key === 'data') {
2382                        markOpt.data = markOpt.data.concat(markData.data);
2383                        markOptR.data = markOptR.data.concat(markData.data);
2384                    } else if (typeof markData[key] != 'object' || markOpt[key] == null) {
2385                        markOpt[key] = markOptR[key] = markData[key];
2386                    } else {
2387                        zrUtil.merge(markOpt[key], markData[key], true);
2388                        zrUtil.merge(markOptR[key], markData[key], true);
2389                    }
2390                }
2391                var chart = this.chart[seriesItem.type];
2392                chart && chart.addMark(seriesIdx, markData, markType);
2393            }
2394            return this;
2395        },
2396        delMarkPoint: function (seriesIdx, markName) {
2397            return this._delMark(seriesIdx, markName, 'markPoint');
2398        },
2399        delMarkLine: function (seriesIdx, markName) {
2400            return this._delMark(seriesIdx, markName, 'markLine');
2401        },
2402        _delMark: function (seriesIdx, markName, markType) {
2403            var series = this._option.series;
2404            var seriesItem;
2405            var mark;
2406            var dataArray;
2407            if (!(series && (seriesItem = series[seriesIdx]) && (mark = seriesItem[markType]) && (dataArray = mark.data))) {
2408                return this;
2409            }
2410            markName = markName.split(' > ');
2411            var targetIndex = -1;
2412            for (var i = 0, l = dataArray.length; i < l; i++) {
2413                var dataItem = dataArray[i];
2414                if (dataItem instanceof Array) {
2415                    if (dataItem[0].name === markName[0] && dataItem[1].name === markName[1]) {
2416                        targetIndex = i;
2417                        break;
2418                    }
2419                } else if (dataItem.name === markName[0]) {
2420                    targetIndex = i;
2421                    break;
2422                }
2423            }
2424            if (targetIndex > -1) {
2425                dataArray.splice(targetIndex, 1);
2426                this._optionRestore.series[seriesIdx][markType].data.splice(targetIndex, 1);
2427                var chart = this.chart[seriesItem.type];
2428                chart && chart.delMark(seriesIdx, markName.join(' > '), markType);
2429            }
2430            return this;
2431        },
2432        getDom: function () {
2433            return this.dom;
2434        },
2435        getZrender: function () {
2436            return this._zr;
2437        },
2438        getDataURL: function (imgType) {
2439            if (!_canvasSupported) {
2440                return '';
2441            }
2442            if (this._chartList.length === 0) {
2443                var imgId = 'IMG' + this.id;
2444                var img = document.getElementById(imgId);
2445                if (img) {
2446                    return img.src;
2447                }
2448            }
2449            var tooltip = this.component.tooltip;
2450            tooltip && tooltip.hideTip();
2451            switch (imgType) {
2452            case 'jpeg':
2453                break;
2454            default:
2455                imgType = 'png';
2456            }
2457            var bgColor = this._option.backgroundColor;
2458            if (bgColor && bgColor.replace(' ', '') === 'rgba(0,0,0,0)') {
2459                bgColor = '#fff';
2460            }
2461            return this._zr.toDataURL('image/' + imgType, bgColor);
2462        },
2463        getImage: function (imgType) {
2464            var title = this._optionRestore.title;
2465            var imgDom = document.createElement('img');
2466            imgDom.src = this.getDataURL(imgType);
2467            imgDom.title = title && title.text || 'ECharts';
2468            return imgDom;
2469        },
2470        getConnectedDataURL: function (imgType) {
2471            if (!this.isConnected()) {
2472                return this.getDataURL(imgType);
2473            }
2474            var tempDom = this.dom;
2475            var imgList = {
2476                'self': {
2477                    img: this.getDataURL(imgType),
2478                    left: tempDom.offsetLeft,
2479                    top: tempDom.offsetTop,
2480                    right: tempDom.offsetLeft + tempDom.offsetWidth,
2481                    bottom: tempDom.offsetTop + tempDom.offsetHeight
2482                }
2483            };
2484            var minLeft = imgList.self.left;
2485            var minTop = imgList.self.top;
2486            var maxRight = imgList.self.right;
2487            var maxBottom = imgList.self.bottom;
2488            for (var c in this._connected) {
2489                tempDom = this._connected[c].getDom();
2490                imgList[c] = {
2491                    img: this._connected[c].getDataURL(imgType),
2492                    left: tempDom.offsetLeft,
2493                    top: tempDom.offsetTop,
2494                    right: tempDom.offsetLeft + tempDom.offsetWidth,
2495                    bottom: tempDom.offsetTop + tempDom.offsetHeight
2496                };
2497                minLeft = Math.min(minLeft, imgList[c].left);
2498                minTop = Math.min(minTop, imgList[c].top);
2499                maxRight = Math.max(maxRight, imgList[c].right);
2500                maxBottom = Math.max(maxBottom, imgList[c].bottom);
2501            }
2502            var zrDom = document.createElement('div');
2503            zrDom.style.position = 'absolute';
2504            zrDom.style.left = '-4000px';
2505            zrDom.style.width = maxRight - minLeft + 'px';
2506            zrDom.style.height = maxBottom - minTop + 'px';
2507            document.body.appendChild(zrDom);
2508            var zrImg = require('zrender').init(zrDom);
2509            var ImageShape = require('zrender/shape/Image');
2510            for (var c in imgList) {
2511                zrImg.addShape(new ImageShape({
2512                    style: {
2513                        x: imgList[c].left - minLeft,
2514                        y: imgList[c].top - minTop,
2515                        image: imgList[c].img
2516                    }
2517                }));
2518            }
2519            zrImg.render();
2520            var bgColor = this._option.backgroundColor;
2521            if (bgColor && bgColor.replace(/ /g, '') === 'rgba(0,0,0,0)') {
2522                bgColor = '#fff';
2523            }
2524            var image = zrImg.toDataURL('image/png', bgColor);
2525            setTimeout(function () {
2526                zrImg.dispose();
2527                zrDom.parentNode.removeChild(zrDom);
2528                zrDom = null;
2529            }, 100);
2530            return image;
2531        },
2532        getConnectedImage: function (imgType) {
2533            var title = this._optionRestore.title;
2534            var imgDom = document.createElement('img');
2535            imgDom.src = this.getConnectedDataURL(imgType);
2536            imgDom.title = title && title.text || 'ECharts';
2537            return imgDom;
2538        },
2539        on: function (eventName, eventListener) {
2540            this._messageCenterOutSide.bind(eventName, eventListener, this);
2541            return this;
2542        },
2543        un: function (eventName, eventListener) {
2544            this._messageCenterOutSide.unbind(eventName, eventListener);
2545            return this;
2546        },
2547        connect: function (connectTarget) {
2548            if (!connectTarget) {
2549                return this;
2550            }
2551            if (!this._connected) {
2552                this._connected = {};
2553            }
2554            if (connectTarget instanceof Array) {
2555                for (var i = 0, l = connectTarget.length; i < l; i++) {
2556                    this._connected[connectTarget[i].id] = connectTarget[i];
2557                }
2558            } else {
2559                this._connected[connectTarget.id] = connectTarget;
2560            }
2561            return this;
2562        },
2563        disConnect: function (connectTarget) {
2564            if (!connectTarget || !this._connected) {
2565                return this;
2566            }
2567            if (connectTarget instanceof Array) {
2568                for (var i = 0, l = connectTarget.length; i < l; i++) {
2569                    delete this._connected[connectTarget[i].id];
2570                }
2571            } else {
2572                delete this._connected[connectTarget.id];
2573            }
2574            for (var k in this._connected) {
2575                return k, this;
2576            }
2577            this._connected = false;
2578            return this;
2579        },
2580        connectedEventHandler: function (param) {
2581            if (param.__echartsId != this.id) {
2582                this._onevent(param);
2583            }
2584        },
2585        isConnected: function () {
2586            return !!this._connected;
2587        },
2588        showLoading: function (loadingOption) {
2589            var effectList = {
2590                bar: require('zrender/loadingEffect/Bar'),
2591                bubble: require('zrender/loadingEffect/Bubble'),
2592                dynamicLine: require('zrender/loadingEffect/DynamicLine'),
2593                ring: require('zrender/loadingEffect/Ring'),
2594                spin: require('zrender/loadingEffect/Spin'),
2595                whirling: require('zrender/loadingEffect/Whirling')
2596            };
2597            this._toolbox.hideDataView();
2598            loadingOption = loadingOption || {};
2599            var textStyle = loadingOption.textStyle || {};
2600            loadingOption.textStyle = textStyle;
2601            var finalTextStyle = zrUtil.merge(zrUtil.merge(zrUtil.clone(textStyle), this._themeConfig.textStyle), ecConfig.textStyle);
2602            textStyle.textFont = finalTextStyle.fontStyle + ' ' + finalTextStyle.fontWeight + ' ' + finalTextStyle.fontSize + 'px ' + finalTextStyle.fontFamily;
2603            textStyle.text = loadingOption.text || this._option && this._option.loadingText || this._themeConfig.loadingText || ecConfig.loadingText;
2604            if (loadingOption.x != null) {
2605                textStyle.x = loadingOption.x;
2606            }
2607            if (loadingOption.y != null) {
2608                textStyle.y = loadingOption.y;
2609            }
2610            loadingOption.effectOption = loadingOption.effectOption || {};
2611            loadingOption.effectOption.textStyle = textStyle;
2612            var Effect = loadingOption.effect;
2613            if (typeof Effect === 'string' || Effect == null) {
2614                Effect = effectList[loadingOption.effect || this._option && this._option.loadingEffect || this._themeConfig.loadingEffect || ecConfig.loadingEffect] || effectList.spin;
2615            }
2616            this._zr.showLoading(new Effect(loadingOption.effectOption));
2617            return this;
2618        },
2619        hideLoading: function () {
2620            this._zr.hideLoading();
2621            return this;
2622        },
2623        setTheme: function (theme) {
2624            if (theme) {
2625                if (typeof theme === 'string') {
2626                    switch (theme) {
2627                    case 'macarons':
2628                        theme = require('./theme/macarons');
2629                        break;
2630                    case 'infographic':
2631                        theme = require('./theme/infographic');
2632                        break;
2633                    default:
2634                        theme = {};
2635                    }
2636                } else {
2637                    theme = theme || {};
2638                }
2639                this._themeConfig = theme;
2640            }
2641            if (!_canvasSupported) {
2642                var textStyle = this._themeConfig.textStyle;
2643                textStyle && textStyle.fontFamily && textStyle.fontFamily2 && (textStyle.fontFamily = textStyle.fontFamily2);
2644                textStyle = ecConfig.textStyle;
2645                textStyle.fontFamily = textStyle.fontFamily2;
2646            }
2647            this._timeline && this._timeline.setTheme(true);
2648            this._optionRestore && this.restore();
2649        },
2650        resize: function () {
2651            var self = this;
2652            return function () {
2653                self._clearEffect();
2654                self._zr.resize();
2655                if (self._option && self._option.renderAsImage && _canvasSupported) {
2656                    self._render(self._option);
2657                    return self;
2658                }
2659                self._zr.clearAnimation();
2660                self._island.resize();
2661                self._toolbox.resize();
2662                self._timeline && self._timeline.resize();
2663                for (var i = 0, l = self._chartList.length; i < l; i++) {
2664                    self._chartList[i].resize && self._chartList[i].resize();
2665                }
2666                self.component.grid && self.component.grid.refixAxisShape(self.component);
2667                self._zr.refresh();
2668                self._messageCenter.dispatch(ecConfig.EVENT.RESIZE, null, null, self);
2669                return self;
2670            };
2671        },
2672        _clearEffect: function () {
2673            this._zr.modLayer(ecConfig.EFFECT_ZLEVEL, { motionBlur: false });
2674            this._zr.painter.clearLayer(ecConfig.EFFECT_ZLEVEL);
2675        },
2676        clear: function () {
2677            this._disposeChartList();
2678            this._zr.clear();
2679            this._option = {};
2680            this._optionRestore = {};
2681            this.dom.style.backgroundColor = null;
2682            return this;
2683        },
2684        dispose: function () {
2685            var key = this.dom.getAttribute(DOM_ATTRIBUTE_KEY);
2686            key && delete _instances[key];
2687            this._island.dispose();
2688            this._toolbox.dispose();
2689            this._timeline && this._timeline.dispose();
2690            this._messageCenter.unbind();
2691            this.clear();
2692            this._zr.dispose();
2693            this._zr = null;
2694        }
2695    };
2696    return self;
2697});define('echarts/config', [], function () {
2698    var config = {
2699        CHART_TYPE_LINE: 'line',
2700        CHART_TYPE_BAR: 'bar',
2701        CHART_TYPE_SCATTER: 'scatter',
2702        CHART_TYPE_PIE: 'pie',
2703        CHART_TYPE_RADAR: 'radar',
2704        CHART_TYPE_VENN: 'venn',
2705        CHART_TYPE_TREEMAP: 'treemap',
2706        CHART_TYPE_TREE: 'tree',
2707        CHART_TYPE_MAP: 'map',
2708        CHART_TYPE_K: 'k',
2709        CHART_TYPE_ISLAND: 'island',
2710        CHART_TYPE_FORCE: 'force',
2711        CHART_TYPE_CHORD: 'chord',
2712        CHART_TYPE_GAUGE: 'gauge',
2713        CHART_TYPE_FUNNEL: 'funnel',
2714        CHART_TYPE_EVENTRIVER: 'eventRiver',
2715        CHART_TYPE_WORDCLOUD: 'wordCloud',
2716        CHART_TYPE_HEATMAP: 'heatmap',
2717        COMPONENT_TYPE_TITLE: 'title',
2718        COMPONENT_TYPE_LEGEND: 'legend',
2719        COMPONENT_TYPE_DATARANGE: 'dataRange',
2720        COMPONENT_TYPE_DATAVIEW: 'dataView',
2721        COMPONENT_TYPE_DATAZOOM: 'dataZoom',
2722        COMPONENT_TYPE_TOOLBOX: 'toolbox',
2723        COMPONENT_TYPE_TOOLTIP: 'tooltip',
2724        COMPONENT_TYPE_GRID: 'grid',
2725        COMPONENT_TYPE_AXIS: 'axis',
2726        COMPONENT_TYPE_POLAR: 'polar',
2727        COMPONENT_TYPE_X_AXIS: 'xAxis',
2728        COMPONENT_TYPE_Y_AXIS: 'yAxis',
2729        COMPONENT_TYPE_AXIS_CATEGORY: 'categoryAxis',
2730        COMPONENT_TYPE_AXIS_VALUE: 'valueAxis',
2731        COMPONENT_TYPE_TIMELINE: 'timeline',
2732        COMPONENT_TYPE_ROAMCONTROLLER: 'roamController',
2733        backgroundColor: 'rgba(0,0,0,0)',
2734        color: [
2735            '#ff7f50',
2736            '#87cefa',
2737            '#da70d6',
2738            '#32cd32',
2739            '#6495ed',
2740            '#ff69b4',
2741            '#ba55d3',
2742            '#cd5c5c',
2743            '#ffa500',
2744            '#40e0d0',
2745            '#1e90ff',
2746            '#ff6347',
2747            '#7b68ee',
2748            '#00fa9a',
2749            '#ffd700',
2750            '#6699FF',
2751            '#ff6666',
2752            '#3cb371',
2753            '#b8860b',
2754            '#30e0e0'
2755        ],
2756        markPoint: {
2757            clickable: true,
2758            symbol: 'pin',
2759            symbolSize: 10,
2760            large: false,
2761            effect: {
2762                show: false,
2763                loop: true,
2764                period: 15,
2765                type: 'scale',
2766                scaleSize: 2,
2767                bounceDistance: 10
2768            },
2769            itemStyle: {
2770                normal: {
2771                    borderWidth: 2,
2772                    label: {
2773                        show: true,
2774                        position: 'inside'
2775                    }
2776                },
2777                emphasis: { label: { show: true } }
2778            }
2779        },
2780        markLine: {
2781            clickable: true,
2782            symbol: [
2783                'circle',
2784                'arrow'
2785            ],
2786            symbolSize: [
2787                2,
2788                4
2789            ],
2790            smoothness: 0.2,
2791            precision: 2,
2792            effect: {
2793                show: false,
2794                loop: true,
2795                period: 15,
2796                scaleSize: 2
2797            },
2798            bundling: {
2799                enable: false,
2800                maxTurningAngle: 45
2801            },
2802            itemStyle: {
2803                normal: {
2804                    borderWidth: 1.5,
2805                    label: {
2806                        show: true,
2807                        position: 'end'
2808                    },
2809                    lineStyle: { type: 'dashed' }
2810                },
2811                emphasis: {
2812                    label: { show: false },
2813                    lineStyle: {}
2814                }
2815            }
2816        },
2817        textStyle: {
2818            decoration: 'none',
2819            fontFamily: 'Arial, Verdana, sans-serif',
2820            fontFamily2: '微软雅黑',
2821            fontSize: 12,
2822            fontStyle: 'normal',
2823            fontWeight: 'normal'
2824        },
2825        EVENT: {
2826            REFRESH: 'refresh',
2827            RESTORE: 'restore',
2828            RESIZE: 'resize',
2829            CLICK: 'click',
2830            DBLCLICK: 'dblclick',
2831            HOVER: 'hover',
2832            MOUSEOUT: 'mouseout',
2833            DATA_CHANGED: 'dataChanged',
2834            DATA_ZOOM: 'dataZoom',
2835            DATA_RANGE: 'dataRange',
2836            DATA_RANGE_SELECTED: 'dataRangeSelected',
2837            DATA_RANGE_HOVERLINK: 'dataRangeHoverLink',
2838            LEGEND_SELECTED: 'legendSelected',
2839            LEGEND_HOVERLINK: 'legendHoverLink',
2840            MAP_SELECTED: 'mapSelected',
2841            PIE_SELECTED: 'pieSelected',
2842            MAGIC_TYPE_CHANGED: 'magicTypeChanged',
2843            DATA_VIEW_CHANGED: 'dataViewChanged',
2844            TIMELINE_CHANGED: 'timelineChanged',
2845            MAP_ROAM: 'mapRoam',
2846            FORCE_LAYOUT_END: 'forceLayoutEnd',
2847            TOOLTIP_HOVER: 'tooltipHover',
2848            TOOLTIP_IN_GRID: 'tooltipInGrid',
2849            TOOLTIP_OUT_GRID: 'tooltipOutGrid',
2850            ROAMCONTROLLER: 'roamController'
2851        },
2852        DRAG_ENABLE_TIME: 120,
2853        EFFECT_ZLEVEL: 10,
2854        effectBlendAlpha: 0.95,
2855        symbolList: [
2856            'circle',
2857            'rectangle',
2858            'triangle',
2859            'diamond',
2860            'emptyCircle',
2861            'emptyRectangle',
2862            'emptyTriangle',
2863            'emptyDiamond'
2864        ],
2865        loadingEffect: 'spin',
2866        loadingText: '数据读取中...',
2867        noDataEffect: 'bubble',
2868        noDataText: '暂无数据',
2869        calculable: false,
2870        calculableColor: 'rgba(255,165,0,0.6)',
2871        calculableHolderColor: '#ccc',
2872        nameConnector: ' & ',
2873        valueConnector: ': ',
2874        animation: true,
2875        addDataAnimation: true,
2876        animationThreshold: 2000,
2877        animationDuration: 2000,
2878        animationDurationUpdate: 500,
2879        animationEasing: 'ExponentialOut'
2880    };
2881    return config;
2882});define('zrender/tool/util', [
2883    'require',
2884    '../dep/excanvas'
2885], function (require) {
2886    var ArrayProto = Array.prototype;
2887    var nativeForEach = ArrayProto.forEach;
2888    var nativeMap = ArrayProto.map;
2889    var nativeFilter = ArrayProto.filter;
2890    var BUILTIN_OBJECT = {
2891        '[object Function]': 1,
2892        '[object RegExp]': 1,
2893        '[object Date]': 1,
2894        '[object Error]': 1,
2895        '[object CanvasGradient]': 1
2896    };
2897    var objToString = Object.prototype.toString;
2898    function isDom(obj) {
2899        return obj && obj.nodeType === 1 && typeof obj.nodeName == 'string';
2900    }
2901    function clone(source) {
2902        if (typeof source == 'object' && source !== null) {
2903            var result = source;
2904            if (source instanceof Array) {
2905                result = [];
2906                for (var i = 0, len = source.length; i < len; i++) {
2907                    result[i] = clone(source[i]);
2908                }
2909            } else if (!BUILTIN_OBJECT[objToString.call(source)] && !isDom(source)) {
2910                result = {};
2911                for (var key in source) {
2912                    if (source.hasOwnProperty(key)) {
2913                        result[key] = clone(source[key]);
2914                    }
2915                }
2916            }
2917            return result;
2918        }
2919        return source;
2920    }
2921    function mergeItem(target, source, key, overwrite) {
2922        if (source.hasOwnProperty(key)) {
2923            var targetProp = target[key];
2924            if (typeof targetProp == 'object' && !BUILTIN_OBJECT[objToString.call(targetProp)] && !isDom(targetProp)) {
2925                merge(target[key], source[key], overwrite);
2926            } else if (overwrite || !(key in target)) {
2927                target[key] = source[key];
2928            }
2929        }
2930    }
2931    function merge(target, source, overwrite) {
2932        for (var i in source) {
2933            mergeItem(target, source, i, overwrite);
2934        }
2935        return target;
2936    }
2937    var _ctx;
2938    function getContext() {
2939        if (!_ctx) {
2940            require('../dep/excanvas');
2941            if (window['G_vmlCanvasManager']) {
2942                var _div = document.createElement('div');
2943                _div.style.position = 'absolute';
2944                _div.style.top = '-1000px';
2945                document.body.appendChild(_div);
2946                _ctx = G_vmlCanvasManager.initElement(_div).getContext('2d');
2947            } else {
2948                _ctx = document.createElement('canvas').getContext('2d');
2949            }
2950        }
2951        return _ctx;
2952    }
2953    function indexOf(array, value) {
2954        if (array.indexOf) {
2955            return array.indexOf(value);
2956        }
2957        for (var i = 0, len = array.length; i < len; i++) {
2958            if (array[i] === value) {
2959                return i;
2960            }
2961        }
2962        return -1;
2963    }
2964    function inherits(clazz, baseClazz) {
2965        var clazzPrototype = clazz.prototype;
2966        function F() {
2967        }
2968        F.prototype = baseClazz.prototype;
2969        clazz.prototype = new F();
2970        for (var prop in clazzPrototype) {
2971            clazz.prototype[prop] = clazzPrototype[prop];
2972        }
2973        clazz.constructor = clazz;
2974    }
2975    function each(obj, cb, context) {
2976        if (!(obj && cb)) {
2977            return;
2978        }
2979        if (obj.forEach && obj.forEach === nativeForEach) {
2980            obj.forEach(cb, context);
2981        } else if (obj.length === +obj.length) {
2982            for (var i = 0, len = obj.length; i < len; i++) {
2983                cb.call(context, obj[i], i, obj);
2984            }
2985        } else {
2986            for (var key in obj) {
2987                if (obj.hasOwnProperty(key)) {
2988                    cb.call(context, obj[key], key, obj);
2989                }
2990            }
2991        }
2992    }
2993    function map(obj, cb, context) {
2994        if (!(obj && cb)) {
2995            return;
2996        }
2997        if (obj.map && obj.map === nativeMap) {
2998            return obj.map(cb, context);
2999        } else {
3000            var result = [];
3001            for (var i = 0, len = obj.length; i < len; i++) {
3002                result.push(cb.call(context, obj[i], i, obj));
3003            }
3004            return result;
3005        }
3006    }
3007    function filter(obj, cb, context) {
3008        if (!(obj && cb)) {
3009            return;
3010        }
3011        if (obj.filter && obj.filter === nativeFilter) {
3012            return obj.filter(cb, context);
3013        } else {
3014            var result = [];
3015            for (var i = 0, len = obj.length; i < len; i++) {
3016                if (cb.call(context, obj[i], i, obj)) {
3017                    result.push(obj[i]);
3018                }
3019            }
3020            return result;
3021        }
3022    }
3023    function bind(func, context) {
3024        return function () {
3025            func.apply(context, arguments);
3026        };
3027    }
3028    return {
3029        inherits: inherits,
3030        clone: clone,
3031        merge: merge,
3032        getContext: getContext,
3033        indexOf: indexOf,
3034        each: each,
3035        map: map,
3036        filter: filter,
3037        bind: bind
3038    };
3039});define('zrender/tool/event', [
3040    'require',
3041    '../mixin/Eventful'
3042], function (require) {
3043    'use strict';
3044    var Eventful = require('../mixin/Eventful');
3045    function getX(e) {
3046        return typeof e.zrenderX != 'undefined' && e.zrenderX || typeof e.offsetX != 'undefined' && e.offsetX || typeof e.layerX != 'undefined' && e.layerX || typeof e.clientX != 'undefined' && e.clientX;
3047    }
3048    function getY(e) {
3049        return typeof e.zrenderY != 'undefined' && e.zrenderY || typeof e.offsetY != 'undefined' && e.offsetY || typeof e.layerY != 'undefined' && e.layerY || typeof e.clientY != 'undefined' && e.clientY;
3050    }
3051    function getDelta(e) {
3052        return typeof e.zrenderDelta != 'undefined' && e.zrenderDelta || typeof e.wheelDelta != 'undefined' && e.wheelDelta || typeof e.detail != 'undefined' && -e.detail;
3053    }
3054    var stop = typeof window.addEventListener === 'function' ? function (e) {
3055        e.preventDefault();
3056        e.stopPropagation();
3057        e.cancelBubble = true;
3058    } : function (e) {
3059        e.returnValue = false;
3060        e.cancelBubble = true;
3061    };
3062    return {
3063        getX: getX,
3064        getY: getY,
3065        getDelta: getDelta,
3066        stop: stop,
3067        Dispatcher: Eventful
3068    };
3069});define('zrender/tool/env', [], function () {
3070    function detect(ua) {
3071        var os = this.os = {};
3072        var browser = this.browser = {};
3073        var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
3074        var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
3075        var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
3076        var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
3077        var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
3078        var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
3079        var touchpad = webos && ua.match(/TouchPad/);
3080        var kindle = ua.match(/Kindle\/([\d.]+)/);
3081        var silk = ua.match(/Silk\/([\d._]+)/);
3082        var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
3083        var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
3084        var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
3085        var playbook = ua.match(/PlayBook/);
3086        var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
3087        var firefox = ua.match(/Firefox\/([\d.]+)/);
3088        var ie = ua.match(/MSIE ([\d.]+)/);
3089        var safari = webkit && ua.match(/Mobile\//) && !chrome;
3090        var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
3091        var ie = ua.match(/MSIE\s([\d.]+)/);
3092        if (browser.webkit = !!webkit)
3093            browser.version = webkit[1];
3094        if (android)
3095            os.android = true, os.version = android[2];
3096        if (iphone && !ipod)
3097            os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
3098        if (ipad)
3099            os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
3100        if (ipod)
3101            os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
3102        if (webos)
3103            os.webos = true, os.version = webos[2];
3104        if (touchpad)
3105            os.touchpad = true;
3106        if (blackberry)
3107            os.blackberry = true, os.version = blackberry[2];
3108        if (bb10)
3109            os.bb10 = true, os.version = bb10[2];
3110        if (rimtabletos)
3111            os.rimtabletos = true, os.version = rimtabletos[2];
3112        if (playbook)
3113            browser.playbook = true;
3114        if (kindle)
3115            os.kindle = true, os.version = kindle[1];
3116        if (silk)
3117            browser.silk = true, browser.version = silk[1];
3118        if (!silk && os.android && ua.match(/Kindle Fire/))
3119            browser.silk = true;
3120        if (chrome)
3121            browser.chrome = true, browser.version = chrome[1];
3122        if (firefox)
3123            browser.firefox = true, browser.version = firefox[1];
3124        if (ie)
3125            browser.ie = true, browser.version = ie[1];
3126        if (safari && (ua.match(/Safari/) || !!os.ios))
3127            browser.safari = true;
3128        if (webview)
3129            browser.webview = true;
3130        if (ie)
3131            browser.ie = true, browser.version = ie[1];
3132        os.tablet = !!(ipad || playbook || android && !ua.match(/Mobile/) || firefox && ua.match(/Tablet/) || ie && !ua.match(/Phone/) && ua.match(/Touch/));
3133        os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || blackberry || bb10 || chrome && ua.match(/Android/) || chrome && ua.match(/CriOS\/([\d.]+)/) || firefox && ua.match(/Mobile/) || ie && ua.match(/Touch/)));
3134        return {
3135            browser: browser,
3136            os: os,
3137            canvasSupported: document.createElement('canvas').getContext ? true : false
3138        };
3139    }
3140    return detect(navigator.userAgent);
3141});define('zrender', ['zrender/zrender'], function (main) {return main;});
3142define('zrender/zrender', [
3143    'require',
3144    './dep/excanvas',
3145    './tool/util',
3146    './tool/log',
3147    './tool/guid',
3148    './Handler',
3149    './Painter',
3150    './Storage',
3151    './animation/Animation',
3152    './tool/env'
3153], function (require) {
3154    require('./dep/excanvas');
3155    var util = require('./tool/util');
3156    var log = require('./tool/log');
3157    var guid = require('./tool/guid');
3158    var Handler = require('./Handler');
3159    var Painter = require('./Painter');
3160    var Storage = require('./Storage');
3161    var Animation = require('./animation/Animation');
3162    var _instances = {};
3163    var zrender = {};
3164    zrender.version = '2.1.1';
3165    zrender.init = function (dom) {
3166        var zr = new ZRender(guid(), dom);
3167        _instances[zr.id] = zr;
3168        return zr;
3169    };
3170    zrender.dispose = function (zr) {
3171        if (zr) {
3172            zr.dispose();
3173        } else {
3174            for (var key in _instances) {
3175                _instances[key].dispose();
3176            }
3177            _instances = {};
3178        }
3179        return zrender;
3180    };
3181    zrender.getInstance = function (id) {
3182        return _instances[id];
3183    };
3184    zrender.delInstance = function (id) {
3185        delete _instances[id];
3186        return zrender;
3187    };
3188    function getFrameCallback(zrInstance) {
3189        return function () {
3190            if (zrInstance._needsRefreshNextFrame) {
3191                zrInstance.refresh();
3192            }
3193        };
3194    }
3195    var ZRender = function (id, dom) {
3196        this.id = id;
3197        this.env = require('./tool/env');
3198        this.storage = new Storage();
3199        this.painter = new Painter(dom, this.storage);
3200        this.handler = new Handler(dom, this.storage, this.painter);
3201        this.animation = new Animation({ stage: { update: getFrameCallback(this) } });
3202        this.animation.start();
3203        var self = this;
3204        this.painter.refreshNextFrame = function () {
3205            self.refreshNextFrame();
3206        };
3207        this._needsRefreshNextFrame = false;
3208        var self = this;
3209        var storage = this.storage;
3210        var oldDelFromMap = storage.delFromMap;
3211        storage.delFromMap = function (elId) {
3212            var el = storage.get(elId);
3213            self.stopAnimation(el);
3214            oldDelFromMap.call(storage, elId);
3215        };
3216    };
3217    ZRender.prototype.getId = function () {
3218        return this.id;
3219    };
3220    ZRender.prototype.addShape = function (shape) {
3221        this.addElement(shape);
3222        return this;
3223    };
3224    ZRender.prototype.addGroup = function (group) {
3225        this.addElement(group);
3226        return this;
3227    };
3228    ZRender.prototype.delShape = function (shapeId) {
3229        this.delElement(shapeId);
3230        return this;
3231    };
3232    ZRender.prototype.delGroup = function (groupId) {
3233        this.delElement(groupId);
3234        return this;
3235    };
3236    ZRender.prototype.modShape = function (shapeId, shape) {
3237        this.modElement(shapeId, shape);
3238        return this;
3239    };
3240    ZRender.prototype.modGroup = function (groupId, group) {
3241        this.modElement(groupId, group);
3242        return this;
3243    };
3244    ZRender.prototype.addElement = function (el) {
3245        this.storage.addRoot(el);
3246        this._needsRefreshNextFrame = true;
3247        return this;
3248    };
3249    ZRender.prototype.delElement = function (el) {
3250        this.storage.delRoot(el);
3251        this._needsRefreshNextFrame = true;
3252        return this;
3253    };
3254    ZRender.prototype.modElement = function (el, params) {
3255        this.storage.mod(el, params);
3256        this._needsRefreshNextFrame = true;
3257        return this;
3258    };
3259    ZRender.prototype.modLayer = function (zLevel, config) {
3260        this.painter.modLayer(zLevel, config);
3261        this._needsRefreshNextFrame = true;
3262        return this;
3263    };
3264    ZRender.prototype.addHoverShape = function (shape) {
3265        this.storage.addHover(shape);
3266        return this;
3267    };
3268    ZRender.prototype.render = function (callback) {
3269        this.painter.render(callback);
3270        this._needsRefreshNextFrame = false;
3271        return this;
3272    };
3273    ZRender.prototype.refresh = function (callback) {
3274        this.painter.refresh(callback);
3275        this._needsRefreshNextFrame = false;
3276        return this;
3277    };
3278    ZRender.prototype.refreshNextFrame = function () {
3279        this._needsRefreshNextFrame = true;
3280        return this;
3281    };
3282    ZRender.prototype.refreshHover = function (callback) {
3283        this.painter.refreshHover(callback);
3284        return this;
3285    };
3286    ZRender.prototype.refreshShapes = function (shapeList, callback) {
3287        this.painter.refreshShapes(shapeList, callback);
3288        return this;
3289    };
3290    ZRender.prototype.resize = function () {
3291        this.painter.resize();
3292        return this;
3293    };
3294    ZRender.prototype.animate = function (el, path, loop) {
3295        var self = this;
3296        if (typeof el === 'string') {
3297            el = this.storage.get(el);
3298        }
3299        if (el) {
3300            var target;
3301            if (path) {
3302                var pathSplitted = path.split('.');
3303                var prop = el;
3304                for (var i = 0, l = pathSplitted.length; i < l; i++) {
3305                    if (!prop) {
3306                        continue;
3307                    }
3308                    prop = prop[pathSplitted[i]];
3309                }
3310                if (prop) {
3311                    target = prop;
3312                }
3313            } else {
3314                target = el;
3315            }
3316            if (!target) {
3317                log('Property "' + path + '" is not existed in element ' + el.id);
3318                return;
3319            }
3320            if (el.__animators == null) {
3321                el.__animators = [];
3322            }
3323            var animators = el.__animators;
3324            var animator = this.animation.animate(target, { loop: loop }).during(function () {
3325                self.modShape(el);
3326            }).done(function () {
3327                var idx = util.indexOf(el.__animators, animator);
3328                if (idx >= 0) {
3329                    animators.splice(idx, 1);
3330                }
3331            });
3332            animators.push(animator);
3333            return animator;
3334        } else {
3335            log('Element not existed');
3336        }
3337    };
3338    ZRender.prototype.stopAnimation = function (el) {
3339        if (el.__animators) {
3340            var animators = el.__animators;
3341            var len = animators.length;
3342            for (var i = 0; i < len; i++) {
3343                animators[i].stop();
3344            }
3345            animators.length = 0;
3346        }
3347        return this;
3348    };
3349    ZRender.prototype.clearAnimation = function () {
3350        this.animation.clear();
3351        return this;
3352    };
3353    ZRender.prototype.showLoading = function (loadingEffect) {
3354        this.painter.showLoading(loadingEffect);
3355        return this;
3356    };
3357    ZRender.prototype.hideLoading = function () {
3358        this.painter.hideLoading();
3359        return this;
3360    };
3361    ZRender.prototype.getWidth = function () {
3362        return this.painter.getWidth();
3363    };
3364    ZRender.prototype.getHeight = function () {
3365        return this.painter.getHeight();
3366    };
3367    ZRender.prototype.toDataURL = function (type, backgroundColor, args) {
3368        return this.painter.toDataURL(type, backgroundColor, args);
3369    };
3370    ZRender.prototype.shapeToImage = function (e, width, height) {
3371        var id = guid();
3372        return this.painter.shapeToImage(id, e, width, height);
3373    };
3374    ZRender.prototype.on = function (eventName, eventHandler, context) {
3375        this.handler.on(eventName, eventHandler, context);
3376        return this;
3377    };
3378    ZRender.prototype.un = function (eventName, eventHandler) {
3379        this.handler.un(eventName, eventHandler);
3380        return this;
3381    };
3382    ZRender.prototype.trigger = function (eventName, event) {
3383        this.handler.trigger(eventName, event);
3384        return this;
3385    };
3386    ZRender.prototype.clear = function () {
3387        this.storage.delRoot();
3388        this.painter.clear();
3389        return this;
3390    };
3391    ZRender.prototype.dispose = function () {
3392        this.animation.stop();
3393        this.clear();
3394        this.storage.dispose();
3395        this.painter.dispose();
3396        this.handler.dispose();
3397        this.animation = this.storage = this.painter = this.handler = null;
3398        zrender.delInstance(this.id);
3399    };
3400    return zrender;
3401});define('zrender/config', [], function () {
3402    var config = {
3403        EVENT: {
3404            RESIZE: 'resize',
3405            CLICK: 'click',
3406            DBLCLICK: 'dblclick',
3407            MOUSEWHEEL: 'mousewheel',
3408            MOUSEMOVE: 'mousemove',
3409            MOUSEOVER: 'mouseover',
3410            MOUSEOUT: 'mouseout',
3411            MOUSEDOWN: 'mousedown',
3412            MOUSEUP: 'mouseup',
3413            GLOBALOUT: 'globalout',
3414            DRAGSTART: 'dragstart',
3415            DRAGEND: 'dragend',
3416            DRAGENTER: 'dragenter',
3417            DRAGOVER: 'dragover',
3418            DRAGLEAVE: 'dragleave',
3419            DROP: 'drop',
3420            touchClickDelay: 300
3421        },
3422        elementClassName: 'zr-element',
3423        catchBrushException: false,
3424        debugMode: 0,
3425        devicePixelRatio: Math.max(window.devicePixelRatio || 1, 1)
3426    };
3427    return config;
3428});define('echarts/chart/island', [
3429    'require',
3430    './base',
3431    'zrender/shape/Circle',
3432    '../config',
3433    '../util/ecData',
3434    'zrender/tool/util',
3435    'zrender/tool/event',
3436    'zrender/tool/color',
3437    '../util/accMath',
3438    '../chart'
3439], function (require) {
3440    var ChartBase = require('./base');
3441    var CircleShape = require('zrender/shape/Circle');
3442    var ecConfig = require('../config');
3443    ecConfig.island = {
3444        zlevel: 0,
3445        z: 5,
3446        r: 15,
3447        calculateStep: 0.1
3448    };
3449    var ecData = require('../util/ecData');
3450    var zrUtil = require('zrender/tool/util');
3451    var zrEvent = require('zrender/tool/event');
3452    function Island(ecTheme, messageCenter, zr, option, myChart) {
3453        ChartBase.call(this, ecTheme, messageCenter, zr, option, myChart);
3454        this._nameConnector;
3455        this._valueConnector;
3456        this._zrHeight = this.zr.getHeight();
3457        this._zrWidth = this.zr.getWidth();
3458        var self = this;
3459        self.shapeHandler.onmousewheel = function (param) {
3460            var shape = param.target;
3461            var event = param.event;
3462            var delta = zrEvent.getDelta(event);
3463            delta = delta > 0 ? -1 : 1;
3464            shape.style.r -= delta;
3465            shape.style.r = shape.style.r < 5 ? 5 : shape.style.r;
3466            var value = ecData.get(shape, 'value');
3467            var dvalue = value * self.option.island.calculateStep;
3468            value = dvalue > 1 ? Math.round(value - dvalue * delta) : +(value - dvalue * delta).toFixed(2);
3469            var name = ecData.get(shape, 'name');
3470            shape.style.text = name + ':' + value;
3471            ecData.set(shape, 'value', value);
3472            ecData.set(shape, 'name', name);
3473            self.zr.modShape(shape.id);
3474            self.zr.refreshNextFrame();
3475            zrEvent.stop(event);
3476        };
3477    }
3478    Island.prototype = {
3479        type: ecConfig.CHART_TYPE_ISLAND,
3480        _combine: function (tarShape, srcShape) {
3481            var zrColor = require('zrender/tool/color');
3482            var accMath = require('../util/accMath');
3483            var value = accMath.accAdd(ecData.get(tarShape, 'value'), ecData.get(srcShape, 'value'));
3484            var name = ecData.get(tarShape, 'name') + this._nameConnector + ecData.get(srcShape, 'name');
3485            tarShape.style.text = name + this._valueConnector + value;
3486            ecData.set(tarShape, 'value', value);
3487            ecData.set(tarShape, 'name', name);
3488            tarShape.style.r = this.option.island.r;
3489            tarShape.style.color = zrColor.mix(tarShape.style.color, srcShape.style.color);
3490        },
3491        refresh: function (newOption) {
3492            if (newOption) {
3493                newOption.island = this.reformOption(newOption.island);
3494                this.option = newOption;
3495                this._nameConnector = this.option.nameConnector;
3496                this._valueConnector = this.option.valueConnector;
3497            }
3498        },
3499        getOption: function () {
3500            return this.option;
3501        },
3502        resize: function () {
3503            var newWidth = this.zr.getWidth();
3504            var newHieght = this.zr.getHeight();
3505            var xScale = newWidth / (this._zrWidth || newWidth);
3506            var yScale = newHieght / (this._zrHeight || newHieght);
3507            if (xScale === 1 && yScale === 1) {
3508                return;
3509            }
3510            this._zrWidth = newWidth;
3511            this._zrHeight = newHieght;
3512            for (var i = 0, l = this.shapeList.length; i < l; i++) {
3513                this.zr.modShape(this.shapeList[i].id, {
3514                    style: {
3515                        x: Math.round(this.shapeList[i].style.x * xScale),
3516                        y: Math.round(this.shapeList[i].style.y * yScale)
3517                    }
3518                });
3519            }
3520        },
3521        add: function (shape) {
3522            var name = ecData.get(shape, 'name');
3523            var value = ecData.get(shape, 'value');
3524            var seriesName = ecData.get(shape, 'series') != null ? ecData.get(shape, 'series').name : '';
3525            var font = this.getFont(this.option.island.textStyle);
3526            var islandOption = this.option.island;
3527            var islandShape = {
3528                zlevel: islandOption.zlevel,
3529                z: islandOption.z,
3530                style: {
3531                    x: shape.style.x,
3532                    y: shape.style.y,
3533                    r: this.option.island.r,
3534                    color: shape.style.color || shape.style.strokeColor,
3535                    text: name + this._valueConnector + value,
3536                    textFont: font
3537                },
3538                draggable: true,
3539                hoverable: true,
3540                onmousewheel: this.shapeHandler.onmousewheel,
3541                _type: 'island'
3542            };
3543            if (islandShape.style.color === '#fff') {
3544                islandShape.style.color = shape.style.strokeColor;
3545            }
3546            this.setCalculable(islandShape);
3547            islandShape.dragEnableTime = 0;
3548            ecData.pack(islandShape, { name: seriesName }, -1, value, -1, name);
3549            islandShape = new CircleShape(islandShape);
3550            this.shapeList.push(islandShape);
3551            this.zr.addShape(islandShape);
3552        },
3553        del: function (shape) {
3554            this.zr.delShape(shape.id);
3555            var newShapeList = [];
3556            for (var i = 0, l = this.shapeList.length; i < l; i++) {
3557                if (this.shapeList[i].id != shape.id) {
3558                    newShapeList.push(this.shapeList[i]);
3559                }
3560            }
3561            this.shapeList = newShapeList;
3562        },
3563        ondrop: function (param, status) {
3564            if (!this.isDrop || !param.target) {
3565                return;
3566            }
3567            var target = param.target;
3568            var dragged = param.dragged;
3569            this._combine(target, dragged);
3570            this.zr.modShape(target.id);
3571            status.dragIn = true;
3572            this.isDrop = false;
3573            return;
3574        },
3575        ondragend: function (param, status) {
3576            var target = param.target;
3577            if (!this.isDragend) {
3578                if (!status.dragIn) {
3579                    target.style.x = zrEvent.getX(param.event);
3580                    target.style.y = zrEvent.getY(param.event);
3581                    this.add(target);
3582                    status.needRefresh = true;
3583                }
3584            } else {
3585                if (status.dragIn) {
3586                    this.del(target);
3587                    status.needRefresh = true;
3588                }
3589            }
3590            this.isDragend = false;
3591            return;
3592        }
3593    };
3594    zrUtil.inherits(Island, ChartBase);
3595    require('../chart').define('island', Island);
3596    return Island;
3597});define('echarts/component/toolbox', [
3598    'require',
3599    './base',
3600    'zrender/shape/Line',
3601    'zrender/shape/Image',
3602    'zrender/shape/Rectangle',
3603    '../util/shape/Icon',
3604    '../config',
3605    'zrender/tool/util',
3606    'zrender/config',
3607    'zrender/tool/event',
3608    './dataView',
3609    '../component'
3610], function (require) {
3611    var Base = require('./base');
3612    var LineShape = require('zrender/shape/Line');
3613    var ImageShape = require('zrender/shape/Image');
3614    var RectangleShape = require('zrender/shape/Rectangle');
3615    var IconShape = require('../util/shape/Icon');
3616    var ecConfig = require('../config');
3617    ecConfig.toolbox = {
3618        zlevel: 0,
3619        z: 6,
3620        show: false,
3621        orient: 'horizontal',
3622        x: 'right',
3623        y: 'top',
3624        color: [
3625            '#1e90ff',
3626            '#22bb22',
3627            '#4b0082',
3628            '#d2691e'
3629        ],
3630        disableColor: '#ddd',
3631        effectiveColor: 'red',
3632        backgroundColor: 'rgba(0,0,0,0)',
3633        borderColor: '#ccc',
3634        borderWidth: 0,
3635        padding: 5,
3636        itemGap: 10,
3637        itemSize: 16,
3638        showTitle: true,
3639        feature: {
3640            mark: {
3641                show: false,
3642                title: {
3643                    mark: '辅助线开关',
3644                    markUndo: '删除辅助线',
3645                    markClear: '清空辅助线'
3646                },
3647                lineStyle: {
3648                    width: 1,
3649                    color: '#1e90ff',
3650                    type: 'dashed'
3651                }
3652            },
3653            dataZoom: {
3654                show: false,
3655                title: {
3656                    dataZoom: '区域缩放',
3657                    dataZoomReset: '区域缩放后退'
3658                }
3659            },
3660            dataView: {
3661                show: false,
3662                title: '数据视图',
3663                readOnly: false,
3664                lang: [
3665                    '数据视图',
3666                    '关闭',
3667                    '刷新'
3668                ]
3669            },
3670            magicType: {
3671                show: false,
3672                title: {
3673                    line: '折线图切换',
3674                    bar: '柱形图切换',
3675                    stack: '堆积',
3676                    tiled: '平铺',
3677                    force: '力导向布局图切换',
3678                    chord: '和弦图切换',
3679                    pie: '饼图切换',
3680                    funnel: '漏斗图切换'
3681                },
3682                type: []
3683            },
3684            restore: {
3685                show: false,
3686                title: '还原'
3687            },
3688            saveAsImage: {
3689                show: false,
3690                title: '保存为图片',
3691                type: 'png',
3692                lang: ['点击保存']
3693            }
3694        }
3695    };
3696    var zrUtil = require('zrender/tool/util');
3697    var zrConfig = require('zrender/config');
3698    var zrEvent = require('zrender/tool/event');
3699    var _MAGICTYPE_STACK = 'stack';
3700    var _MAGICTYPE_TILED = 'tiled';
3701    function Toolbox(ecTheme, messageCenter, zr, option, myChart) {
3702        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
3703        this.dom = myChart.dom;
3704        this._magicType = {};
3705        this._magicMap = {};
3706        this._isSilence = false;
3707        this._iconList;
3708        this._iconShapeMap = {};
3709        this._featureTitle = {};
3710        this._featureIcon = {};
3711        this._featureColor = {};
3712        this._featureOption = {};
3713        this._enableColor = 'red';
3714        this._disableColor = '#ccc';
3715        this._markShapeList = [];
3716        var self = this;
3717        self._onMark = function (param) {
3718            self.__onMark(param);
3719        };
3720        self._onMarkUndo = function (param) {
3721            self.__onMarkUndo(param);
3722        };
3723        self._onMarkClear = function (param) {
3724            self.__onMarkClear(param);
3725        };
3726        self._onDataZoom = function (param) {
3727            self.__onDataZoom(param);
3728        };
3729        self._onDataZoomReset = function (param) {
3730            self.__onDataZoomReset(param);
3731        };
3732        self._onDataView = function (param) {
3733            self.__onDataView(param);
3734        };
3735        self._onRestore = function (param) {
3736            self.__onRestore(param);
3737        };
3738        self._onSaveAsImage = function (param) {
3739            self.__onSaveAsImage(param);
3740        };
3741        self._onMagicType = function (param) {
3742            self.__onMagicType(param);
3743        };
3744        self._onCustomHandler = function (param) {
3745            self.__onCustomHandler(param);
3746        };
3747        self._onmousemove = function (param) {
3748            return self.__onmousemove(param);
3749        };
3750        self._onmousedown = function (param) {
3751            return self.__onmousedown(param);
3752        };
3753        self._onmouseup = function (param) {
3754            return self.__onmouseup(param);
3755        };
3756        self._onclick = function (param) {
3757            return self.__onclick(param);
3758        };
3759    }
3760    Toolbox.prototype = {
3761        type: ecConfig.COMPONENT_TYPE_TOOLBOX,
3762        _buildShape: function () {
3763            this._iconList = [];
3764            var toolboxOption = this.option.toolbox;
3765            this._enableColor = toolboxOption.effectiveColor;
3766            this._disableColor = toolboxOption.disableColor;
3767            var feature = toolboxOption.feature;
3768            var iconName = [];
3769            for (var key in feature) {
3770                if (feature[key].show) {
3771                    switch (key) {
3772                    case 'mark':
3773                        iconName.push({
3774                            key: key,
3775                            name: 'mark'
3776                        });
3777                        iconName.push({
3778                            key: key,
3779                            name: 'markUndo'
3780                        });
3781                        iconName.push({
3782                            key: key,
3783                            name: 'markClear'
3784                        });
3785                        break;
3786                    case 'magicType':
3787                        for (var i = 0, l = feature[key].type.length; i < l; i++) {
3788                            feature[key].title[feature[key].type[i] + 'Chart'] = feature[key].title[feature[key].type[i]];
3789                            if (feature[key].option) {
3790                                feature[key].option[feature[key].type[i] + 'Chart'] = feature[key].option[feature[key].type[i]];
3791                            }
3792                            iconName.push({
3793                                key: key,
3794                                name: feature[key].type[i] + 'Chart'
3795                            });
3796                        }
3797                        break;
3798                    case 'dataZoom':
3799                        iconName.push({
3800                            key: key,
3801                            name: 'dataZoom'
3802                        });
3803                        iconName.push({
3804                            key: key,
3805                            name: 'dataZoomReset'
3806                        });
3807                        break;
3808                    case 'saveAsImage':
3809                        if (this.canvasSupported) {
3810                            iconName.push({
3811                                key: key,
3812                                name: 'saveAsImage'
3813                            });
3814                        }
3815                        break;
3816                    default:
3817                        iconName.push({
3818                            key: key,
3819                            name: key
3820                        });
3821                        break;
3822                    }
3823                }
3824            }
3825            if (iconName.length > 0) {
3826                var name;
3827                var key;
3828                for (var i = 0, l = iconName.length; i < l; i++) {
3829                    name = iconName[i].name;
3830                    key = iconName[i].key;
3831                    this._iconList.push(name);
3832                    this._featureTitle[name] = feature[key].title[name] || feature[key].title;
3833                    if (feature[key].icon) {
3834                        this._featureIcon[name] = feature[key].icon[name] || feature[key].icon;
3835                    }
3836                    if (feature[key].color) {
3837                        this._featureColor[name] = feature[key].color[name] || feature[key].color;
3838                    }
3839                    if (feature[key].option) {
3840                        this._featureOption[name] = feature[key].option[name] || feature[key].option;
3841                    }
3842                }
3843                this._itemGroupLocation = this._getItemGroupLocation();
3844                this._buildBackground();
3845                this._buildItem();
3846                for (var i = 0, l = this.shapeList.length; i < l; i++) {
3847                    this.zr.addShape(this.shapeList[i]);
3848                }
3849                if (this._iconShapeMap['mark']) {
3850                    this._iconDisable(this._iconShapeMap['markUndo']);
3851                    this._iconDisable(this._iconShapeMap['markClear']);
3852                }
3853                if (this._iconShapeMap['dataZoomReset'] && this._zoomQueue.length === 0) {
3854                    this._iconDisable(this._iconShapeMap['dataZoomReset']);
3855                }
3856            }
3857        },
3858        _buildItem: function () {
3859            var toolboxOption = this.option.toolbox;
3860            var iconLength = this._iconList.length;
3861            var lastX = this._itemGroupLocation.x;
3862            var lastY = this._itemGroupLocation.y;
3863            var itemSize = toolboxOption.itemSize;
3864            var itemGap = toolboxOption.itemGap;
3865            var itemShape;
3866            var color = toolboxOption.color instanceof Array ? toolboxOption.color : [toolboxOption.color];
3867            var textFont = this.getFont(toolboxOption.textStyle);
3868            var textPosition;
3869            var textAlign;
3870            var textBaseline;
3871            if (toolboxOption.orient === 'horizontal') {
3872                textPosition = this._itemGroupLocation.y / this.zr.getHeight() < 0.5 ? 'bottom' : 'top';
3873                textAlign = this._itemGroupLocation.x / this.zr.getWidth() < 0.5 ? 'left' : 'right';
3874                textBaseline = this._itemGroupLocation.y / this.zr.getHeight() < 0.5 ? 'top' : 'bottom';
3875            } else {
3876                textPosition = this._itemGroupLocation.x / this.zr.getWidth() < 0.5 ? 'right' : 'left';
3877            }
3878            this._iconShapeMap = {};
3879            var self = this;
3880            for (var i = 0; i < iconLength; i++) {
3881                itemShape = {
3882                    type: 'icon',
3883                    zlevel: this.getZlevelBase(),
3884                    z: this.getZBase(),
3885                    style: {
3886                        x: lastX,
3887                        y: lastY,
3888                        width: itemSize,
3889                        height: itemSize,
3890                        iconType: this._iconList[i],
3891                        lineWidth: 1,
3892                        strokeColor: this._featureColor[this._iconList[i]] || color[i % color.length],
3893                        brushType: 'stroke'
3894                    },
3895                    highlightStyle: {
3896                        lineWidth: 1,
3897                        text: toolboxOption.showTitle ? this._featureTitle[this._iconList[i]] : undefined,
3898                        textFont: textFont,
3899                        textPosition: textPosition,
3900                        strokeColor: this._featureColor[this._iconList[i]] || color[i % color.length]
3901                    },
3902                    hoverable: true,
3903                    clickable: true
3904                };
3905                if (this._featureIcon[this._iconList[i]]) {
3906                    itemShape.style.image = this._featureIcon[this._iconList[i]].replace(new RegExp('^image:\\/\\/'), '');
3907                    itemShape.style.opacity = 0.8;
3908                    itemShape.highlightStyle.opacity = 1;
3909                    itemShape.type = 'image';
3910                }
3911                if (toolboxOption.orient === 'horizontal') {
3912                    if (i === 0 && textAlign === 'left') {
3913                        itemShape.highlightStyle.textPosition = 'specific';
3914                        itemShape.highlightStyle.textAlign = textAlign;
3915                        itemShape.highlightStyle.textBaseline = textBaseline;
3916                        itemShape.highlightStyle.textX = lastX;
3917                        itemShape.highlightStyle.textY = textBaseline === 'top' ? lastY + itemSize + 10 : lastY - 10;
3918                    }
3919                    if (i === iconLength - 1 && textAlign === 'right') {
3920                        itemShape.highlightStyle.textPosition = 'specific';
3921                        itemShape.highlightStyle.textAlign = textAlign;
3922                        itemShape.highlightStyle.textBaseline = textBaseline;
3923                        itemShape.highlightStyle.textX = lastX + itemSize;
3924                        itemShape.highlightStyle.textY = textBaseline === 'top' ? lastY + itemSize + 10 : lastY - 10;
3925                    }
3926                }
3927                switch (this._iconList[i]) {
3928                case 'mark':
3929                    itemShape.onclick = self._onMark;
3930                    break;
3931                case 'markUndo':
3932                    itemShape.onclick = self._onMarkUndo;
3933                    break;
3934                case 'markClear':
3935                    itemShape.onclick = self._onMarkClear;
3936                    break;
3937                case 'dataZoom':
3938                    itemShape.onclick = self._onDataZoom;
3939                    break;
3940                case 'dataZoomReset':
3941                    itemShape.onclick = self._onDataZoomReset;
3942                    break;
3943                case 'dataView':
3944                    if (!this._dataView) {
3945                        var DataView = require('./dataView');
3946                        this._dataView = new DataView(this.ecTheme, this.messageCenter, this.zr, this.option, this.myChart);
3947                    }
3948                    itemShape.onclick = self._onDataView;
3949                    break;
3950                case 'restore':
3951                    itemShape.onclick = self._onRestore;
3952                    break;
3953                case 'saveAsImage':
3954                    itemShape.onclick = self._onSaveAsImage;
3955                    break;
3956                default:
3957                    if (this._iconList[i].match('Chart')) {
3958                        itemShape._name = this._iconList[i].replace('Chart', '');
3959                        itemShape.onclick = self._onMagicType;
3960                    } else {
3961                        itemShape.onclick = self._onCustomHandler;
3962                    }
3963                    break;
3964                }
3965                if (itemShape.type === 'icon') {
3966                    itemShape = new IconShape(itemShape);
3967                } else if (itemShape.type === 'image') {
3968                    itemShape = new ImageShape(itemShape);
3969                }
3970                this.shapeList.push(itemShape);
3971                this._iconShapeMap[this._iconList[i]] = itemShape;
3972                if (toolboxOption.orient === 'horizontal') {
3973                    lastX += itemSize + itemGap;
3974                } else {
3975                    lastY += itemSize + itemGap;
3976                }
3977            }
3978        },
3979        _buildBackground: function () {
3980            var toolboxOption = this.option.toolbox;
3981            var padding = this.reformCssArray(this.option.toolbox.padding);
3982            this.shapeList.push(new RectangleShape({
3983                zlevel: this.getZlevelBase(),
3984                z: this.getZBase(),
3985                hoverable: false,
3986                style: {
3987                    x: this._itemGroupLocation.x - padding[3],
3988                    y: this._itemGroupLocation.y - padding[0],
3989                    width: this._itemGroupLocation.width + padding[3] + padding[1],
3990                    height: this._itemGroupLocation.height + padding[0] + padding[2],
3991                    brushType: toolboxOption.borderWidth === 0 ? 'fill' : 'both',
3992                    color: toolboxOption.backgroundColor,
3993                    strokeColor: toolboxOption.borderColor,
3994                    lineWidth: toolboxOption.borderWidth
3995                }
3996            }));
3997        },
3998        _getItemGroupLocation: function () {
3999            var toolboxOption = this.option.toolbox;
4000            var padding = this.reformCssArray(this.option.toolbox.padding);
4001            var iconLength = this._iconList.length;
4002            var itemGap = toolboxOption.itemGap;
4003            var itemSize = toolboxOption.itemSize;
4004            var totalWidth = 0;
4005            var totalHeight = 0;
4006            if (toolboxOption.orient === 'horizontal') {
4007                totalWidth = (itemSize + itemGap) * iconLength - itemGap;
4008                totalHeight = itemSize;
4009            } else {
4010                totalHeight = (itemSize + itemGap) * iconLength - itemGap;
4011                totalWidth = itemSize;
4012            }
4013            var x;
4014            var zrWidth = this.zr.getWidth();
4015            switch (toolboxOption.x) {
4016            case 'center':
4017                x = Math.floor((zrWidth - totalWidth) / 2);
4018                break;
4019            case 'left':
4020                x = padding[3] + toolboxOption.borderWidth;
4021                break;
4022            case 'right':
4023                x = zrWidth - totalWidth - padding[1] - toolboxOption.borderWidth;
4024                break;
4025            default:
4026                x = toolboxOption.x - 0;
4027                x = isNaN(x) ? 0 : x;
4028                break;
4029            }
4030            var y;
4031            var zrHeight = this.zr.getHeight();
4032            switch (toolboxOption.y) {
4033            case 'top':
4034                y = padding[0] + toolboxOption.borderWidth;
4035                break;
4036            case 'bottom':
4037                y = zrHeight - totalHeight - padding[2] - toolboxOption.borderWidth;
4038                break;
4039            case 'center':
4040                y = Math.floor((zrHeight - totalHeight) / 2);
4041                break;
4042            default:
4043                y = toolboxOption.y - 0;
4044                y = isNaN(y) ? 0 : y;
4045                break;
4046            }
4047            return {
4048                x: x,
4049                y: y,
4050                width: totalWidth,
4051                height: totalHeight
4052            };
4053        },
4054        __onmousemove: function (param) {
4055            if (this._marking) {
4056                this._markShape.style.xEnd = zrEvent.getX(param.event);
4057                this._markShape.style.yEnd = zrEvent.getY(param.event);
4058                this.zr.addHoverShape(this._markShape);
4059            }
4060            if (this._zooming) {
4061                this._zoomShape.style.width = zrEvent.getX(param.event) - this._zoomShape.style.x;
4062                this._zoomShape.style.height = zrEvent.getY(param.event) - this._zoomShape.style.y;
4063                this.zr.addHoverShape(this._zoomShape);
4064                this.dom.style.cursor = 'crosshair';
4065                zrEvent.stop(param.event);
4066            }
4067            if (this._zoomStart && (this.dom.style.cursor != 'pointer' && this.dom.style.cursor != 'move')) {
4068                this.dom.style.cursor = 'crosshair';
4069            }
4070        },
4071        __onmousedown: function (param) {
4072            if (param.target) {
4073                return;
4074            }
4075            this._zooming = true;
4076            var x = zrEvent.getX(param.event);
4077            var y = zrEvent.getY(param.event);
4078            var zoomOption = this.option.dataZoom || {};
4079            this._zoomShape = new RectangleShape({
4080                zlevel: this.getZlevelBase(),
4081                z: this.getZBase(),
4082                style: {
4083                    x: x,
4084                    y: y,
4085                    width: 1,
4086                    height: 1,
4087                    brushType: 'both'
4088                },
4089                highlightStyle: {
4090                    lineWidth: 2,
4091                    color: zoomOption.fillerColor || ecConfig.dataZoom.fillerColor,
4092                    strokeColor: zoomOption.handleColor || ecConfig.dataZoom.handleColor,
4093                    brushType: 'both'
4094                }
4095            });
4096            this.zr.addHoverShape(this._zoomShape);
4097            return true;
4098        },
4099        __onmouseup: function () {
4100            if (!this._zoomShape || Math.abs(this._zoomShape.style.width) < 10 || Math.abs(this._zoomShape.style.height) < 10) {
4101                this._zooming = false;
4102                return true;
4103            }
4104            if (this._zooming && this.component.dataZoom) {
4105                this._zooming = false;
4106                var zoom = this.component.dataZoom.rectZoom(this._zoomShape.style);
4107                if (zoom) {
4108                    this._zoomQueue.push({
4109                        start: zoom.start,
4110                        end: zoom.end,
4111                        start2: zoom.start2,
4112                        end2: zoom.end2
4113                    });
4114                    this._iconEnable(this._iconShapeMap['dataZoomReset']);
4115                    this.zr.refreshNextFrame();
4116                }
4117            }
4118            return true;
4119        },
4120        __onclick: function (param) {
4121            if (param.target) {
4122                return;
4123            }
4124            if (this._marking) {
4125                this._marking = false;
4126                this._markShapeList.push(this._markShape);
4127                this._iconEnable(this._iconShapeMap['markUndo']);
4128                this._iconEnable(this._iconShapeMap['markClear']);
4129                this.zr.addShape(this._markShape);
4130                this.zr.refreshNextFrame();
4131            } else if (this._markStart) {
4132                this._marking = true;
4133                var x = zrEvent.getX(param.event);
4134                var y = zrEvent.getY(param.event);
4135                this._markShape = new LineShape({
4136                    zlevel: this.getZlevelBase(),
4137                    z: this.getZBase(),
4138                    style: {
4139                        xStart: x,
4140                        yStart: y,
4141                        xEnd: x,
4142                        yEnd: y,
4143                        lineWidth: this.query(this.option, 'toolbox.feature.mark.lineStyle.width'),
4144                        strokeColor: this.query(this.option, 'toolbox.feature.mark.lineStyle.color'),
4145                        lineType: this.query(this.option, 'toolbox.feature.mark.lineStyle.type')
4146                    }
4147                });
4148                this.zr.addHoverShape(this._markShape);
4149            }
4150        },
4151        __onMark: function (param) {
4152            var target = param.target;
4153            if (this._marking || this._markStart) {
4154                this._resetMark();
4155                this.zr.refreshNextFrame();
4156            } else {
4157                this._resetZoom();
4158                this.zr.modShape(target.id, { style: { strokeColor: this._enableColor } });
4159                this.zr.refreshNextFrame();
4160                this._markStart = true;
4161                var self = this;
4162                setTimeout(function () {
4163                    self.zr && self.zr.on(zrConfig.EVENT.CLICK, self._onclick) && self.zr.on(zrConfig.EVENT.MOUSEMOVE, self._onmousemove);
4164                }, 10);
4165            }
4166            return true;
4167        },
4168        __onMarkUndo: function () {
4169            if (this._marking) {
4170                this._marking = false;
4171            } else {
4172                var len = this._markShapeList.length;
4173                if (len >= 1) {
4174                    var target = this._markShapeList[len - 1];
4175                    this.zr.delShape(target.id);
4176                    this.zr.refreshNextFrame();
4177                    this._markShapeList.pop();
4178                    if (len === 1) {
4179                        this._iconDisable(this._iconShapeMap['markUndo']);
4180                        this._iconDisable(this._iconShapeMap['markClear']);
4181                    }
4182                }
4183            }
4184            return true;
4185        },
4186        __onMarkClear: function () {
4187            if (this._marking) {
4188                this._marking = false;
4189            }
4190            var len = this._markShapeList.length;
4191            if (len > 0) {
4192                while (len--) {
4193                    this.zr.delShape(this._markShapeList.pop().id);
4194                }
4195                this._iconDisable(this._iconShapeMap['markUndo']);
4196                this._iconDisable(this._iconShapeMap['markClear']);
4197                this.zr.refreshNextFrame();
4198            }
4199            return true;
4200        },
4201        __onDataZoom: function (param) {
4202            var target = param.target;
4203            if (this._zooming || this._zoomStart) {
4204                this._resetZoom();
4205                this.zr.refreshNextFrame();
4206                this.dom.style.cursor = 'default';
4207            } else {
4208                this._resetMark();
4209                this.zr.modShape(target.id, { style: { strokeColor: this._enableColor } });
4210                this.zr.refreshNextFrame();
4211                this._zoomStart = true;
4212                var self = this;
4213                setTimeout(function () {
4214                    self.zr && self.zr.on(zrConfig.EVENT.MOUSEDOWN, self._onmousedown) && self.zr.on(zrConfig.EVENT.MOUSEUP, self._onmouseup) && self.zr.on(zrConfig.EVENT.MOUSEMOVE, self._onmousemove);
4215                }, 10);
4216                this.dom.style.cursor = 'crosshair';
4217            }
4218            return true;
4219        },
4220        __onDataZoomReset: function () {
4221            if (this._zooming) {
4222                this._zooming = false;
4223            }
4224            this._zoomQueue.pop();
4225            if (this._zoomQueue.length > 0) {
4226                this.component.dataZoom.absoluteZoom(this._zoomQueue[this._zoomQueue.length - 1]);
4227            } else {
4228                this.component.dataZoom.rectZoom();
4229                this._iconDisable(this._iconShapeMap['dataZoomReset']);
4230                this.zr.refreshNextFrame();
4231            }
4232            return true;
4233        },
4234        _resetMark: function () {
4235            this._marking = false;
4236            if (this._markStart) {
4237                this._markStart = false;
4238                if (this._iconShapeMap['mark']) {
4239                    this.zr.modShape(this._iconShapeMap['mark'].id, { style: { strokeColor: this._iconShapeMap['mark'].highlightStyle.strokeColor } });
4240                }
4241                this.zr.un(zrConfig.EVENT.CLICK, this._onclick);
4242                this.zr.un(zrConfig.EVENT.MOUSEMOVE, this._onmousemove);
4243            }
4244        },
4245        _resetZoom: function () {
4246            this._zooming = false;
4247            if (this._zoomStart) {
4248                this._zoomStart = false;
4249                if (this._iconShapeMap['dataZoom']) {
4250                    this.zr.modShape(this._iconShapeMap['dataZoom'].id, { style: { strokeColor: this._iconShapeMap['dataZoom'].highlightStyle.strokeColor } });
4251                }
4252                this.zr.un(zrConfig.EVENT.MOUSEDOWN, this._onmousedown);
4253                this.zr.un(zrConfig.EVENT.MOUSEUP, this._onmouseup);
4254                this.zr.un(zrConfig.EVENT.MOUSEMOVE, this._onmousemove);
4255            }
4256        },
4257        _iconDisable: function (target) {
4258            if (target.type != 'image') {
4259                this.zr.modShape(target.id, {
4260                    hoverable: false,
4261                    clickable: false,
4262                    style: { strokeColor: this._disableColor }
4263                });
4264            } else {
4265                this.zr.modShape(target.id, {
4266                    hoverable: false,
4267                    clickable: false,
4268                    style: { opacity: 0.3 }
4269                });
4270            }
4271        },
4272        _iconEnable: function (target) {
4273            if (target.type != 'image') {
4274                this.zr.modShape(target.id, {
4275                    hoverable: true,
4276                    clickable: true,
4277                    style: { strokeColor: target.highlightStyle.strokeColor }
4278                });
4279            } else {
4280                this.zr.modShape(target.id, {
4281                    hoverable: true,
4282                    clickable: true,
4283                    style: { opacity: 0.8 }
4284                });
4285            }
4286        },
4287        __onDataView: function () {
4288            this._dataView.show(this.option);
4289            return true;
4290        },
4291        __onRestore: function () {
4292            this._resetMark();
4293            this._resetZoom();
4294            this.messageCenter.dispatch(ecConfig.EVENT.RESTORE, null, null, this.myChart);
4295            return true;
4296        },
4297        __onSaveAsImage: function () {
4298            var saveOption = this.option.toolbox.feature.saveAsImage;
4299            var imgType = saveOption.type || 'png';
4300            if (imgType != 'png' && imgType != 'jpeg') {
4301                imgType = 'png';
4302            }
4303            var image;
4304            if (!this.myChart.isConnected()) {
4305                image = this.zr.toDataURL('image/' + imgType, this.option.backgroundColor && this.option.backgroundColor.replace(' ', '') === 'rgba(0,0,0,0)' ? '#fff' : this.option.backgroundColor);
4306            } else {
4307                image = this.myChart.getConnectedDataURL(imgType);
4308            }
4309            var downloadDiv = document.createElement('div');
4310            downloadDiv.id = '__echarts_download_wrap__';
4311            downloadDiv.style.cssText = 'position:fixed;' + 'z-index:99999;' + 'display:block;' + 'top:0;left:0;' + 'background-color:rgba(33,33,33,0.5);' + 'text-align:center;' + 'width:100%;' + 'height:100%;' + 'line-height:' + document.documentElement.clientHeight + 'px;';
4312            var downloadLink = document.createElement('a');
4313            downloadLink.href = image;
4314            downloadLink.setAttribute('download', (saveOption.name ? saveOption.name : this.option.title && (this.option.title.text || this.option.title.subtext) ? this.option.title.text || this.option.title.subtext : 'ECharts') + '.' + imgType);
4315            downloadLink.innerHTML = '<img style="vertical-align:middle" src="' + image 
4315+ '" title="' + (!!window.ActiveXObject || 'ActiveXObject' in window ? '右键->图片另存为' : saveOption.lang ? saveOption.lang[0] : '点击保存') + '"/>';
4316            downloadDiv.appendChild(downloadLink);
4317            document.body.appendChild(downloadDiv);
4318            downloadLink = null;
4319            downloadDiv = null;
4320            setTimeout(function () {
4321                var _d = document.getElementById('__echarts_download_wrap__');
4322                if (_d) {
4323                    _d.onclick = function () {
4324                        var d = document.getElementById('__echarts_download_wrap__');
4325                        d.onclick = null;
4326                        d.innerHTML = '';
4327                        document.body.removeChild(d);
4328                        d = null;
4329                    };
4330                    _d = null;
4331                }
4332            }, 500);
4333            return;
4334        },
4335        __onMagicType: function (param) {
4336            this._resetMark();
4337            var itemName = param.target._name;
4338            if (!this._magicType[itemName]) {
4339                this._magicType[itemName] = true;
4340                if (itemName === ecConfig.CHART_TYPE_LINE) {
4341                    this._magicType[ecConfig.CHART_TYPE_BAR] = false;
4342                } else if (itemName === ecConfig.CHART_TYPE_BAR) {
4343                    this._magicType[ecConfig.CHART_TYPE_LINE] = false;
4344                }
4345                if (itemName === ecConfig.CHART_TYPE_PIE) {
4346                    this._magicType[ecConfig.CHART_TYPE_FUNNEL] = false;
4347                } else if (itemName === ecConfig.CHART_TYPE_FUNNEL) {
4348                    this._magicType[ecConfig.CHART_TYPE_PIE] = false;
4349                }
4350                if (itemName === ecConfig.CHART_TYPE_FORCE) {
4351                    this._magicType[ecConfig.CHART_TYPE_CHORD] = false;
4352                } else if (itemName === ecConfig.CHART_TYPE_CHORD) {
4353                    this._magicType[ecConfig.CHART_TYPE_FORCE] = false;
4354                }
4355                if (itemName === _MAGICTYPE_STACK) {
4356                    this._magicType[_MAGICTYPE_TILED] = false;
4357                } else if (itemName === _MAGICTYPE_TILED) {
4358                    this._magicType[_MAGICTYPE_STACK] = false;
4359                }
4360                this.messageCenter.dispatch(ecConfig.EVENT.MAGIC_TYPE_CHANGED, param.event, { magicType: this._magicType }, this.myChart);
4361            }
4362            return true;
4363        },
4364        setMagicType: function (magicType) {
4365            this._resetMark();
4366            this._magicType = magicType;
4367            !this._isSilence && this.messageCenter.dispatch(ecConfig.EVENT.MAGIC_TYPE_CHANGED, null, { magicType: this._magicType }, this.myChart);
4368        },
4369        __onCustomHandler: function (param) {
4370            var target = param.target.style.iconType;
4371            var featureHandler = this.option.toolbox.feature[target].onclick;
4372            if (typeof featureHandler === 'function') {
4373                featureHandler.call(this, this.option);
4374            }
4375        },
4376        reset: function (newOption, isRestore) {
4377            isRestore && this.clear();
4378            if (this.query(newOption, 'toolbox.show') && this.query(newOption, 'toolbox.feature.magicType.show')) {
4379                var magicType = newOption.toolbox.feature.magicType.type;
4380                var len = magicType.length;
4381                this._magicMap = {};
4382                while (len--) {
4383                    this._magicMap[magicType[len]] = true;
4384                }
4385                len = newOption.series.length;
4386                var oriType;
4387                var axis;
4388                while (len--) {
4389                    oriType = newOption.series[len].type;
4390                    if (this._magicMap[oriType]) {
4391                        axis = newOption.xAxis instanceof Array ? newOption.xAxis[newOption.series[len].xAxisIndex || 0] : newOption.xAxis;
4392                        if (axis && (axis.type || 'category') === 'category') {
4393                            axis.__boundaryGap = axis.boundaryGap != null ? axis.boundaryGap : true;
4394                        }
4395                        axis = newOption.yAxis instanceof Array ? newOption.yAxis[newOption.series[len].yAxisIndex || 0] : newOption.yAxis;
4396                        if (axis && axis.type === 'category') {
4397                            axis.__boundaryGap = axis.boundaryGap != null ? axis.boundaryGap : true;
4398                        }
4399                        newOption.series[len].__type = oriType;
4400                        newOption.series[len].__itemStyle = zrUtil.clone(newOption.series[len].itemStyle || {});
4401                    }
4402                    if (this._magicMap[_MAGICTYPE_STACK] || this._magicMap[_MAGICTYPE_TILED]) {
4403                        newOption.series[len].__stack = newOption.series[len].stack;
4404                    }
4405                }
4406            }
4407            this._magicType = isRestore ? {} : this._magicType || {};
4408            for (var itemName in this._magicType) {
4409                if (this._magicType[itemName]) {
4410                    this.option = newOption;
4411                    this.getMagicOption();
4412                    break;
4413                }
4414            }
4415            var zoomOption = newOption.dataZoom;
4416            if (zoomOption && zoomOption.show) {
4417                var start = zoomOption.start != null && zoomOption.start >= 0 && zoomOption.start <= 100 ? zoomOption.start : 0;
4418                var end = zoomOption.end != null && zoomOption.end >= 0 && zoomOption.end <= 100 ? zoomOption.end : 100;
4419                if (start > end) {
4420                    start = start + end;
4421                    end = start - end;
4422                    start = start - end;
4423                }
4424                this._zoomQueue = [{
4425                        start: start,
4426                        end: end,
4427                        start2: 0,
4428                        end2: 100
4429                    }];
4430            } else {
4431                this._zoomQueue = [];
4432            }
4433        },
4434        getMagicOption: function () {
4435            var axis;
4436            var chartType;
4437            if (this._magicType[ecConfig.CHART_TYPE_LINE] || this._magicType[ecConfig.CHART_TYPE_BAR]) {
4438                var boundaryGap = this._magicType[ecConfig.CHART_TYPE_LINE] ? false : true;
4439                for (var i = 0, l = this.option.series.length; i < l; i++) {
4440                    chartType = this.option.series[i].type;
4441                    if (chartType == ecConfig.CHART_TYPE_LINE || chartType == ecConfig.CHART_TYPE_BAR) {
4442                        axis = this.option.xAxis instanceof Array ? this.option.xAxis[this.option.series[i].xAxisIndex || 0] : this.option.xAxis;
4443                        if (axis && (axis.type || 'category') === 'category') {
4444                            axis.boundaryGap = boundaryGap ? true : axis.__boundaryGap;
4445                        }
4446                        axis = this.option.yAxis instanceof Array ? this.option.yAxis[this.option.series[i].yAxisIndex || 0] : this.option.yAxis;
4447                        if (axis && axis.type === 'category') {
4448                            axis.boundaryGap = boundaryGap ? true : axis.__boundaryGap;
4449                        }
4450                    }
4451                }
4452                this._defaultMagic(ecConfig.CHART_TYPE_LINE, ecConfig.CHART_TYPE_BAR);
4453            }
4454            this._defaultMagic(ecConfig.CHART_TYPE_CHORD, ecConfig.CHART_TYPE_FORCE);
4455            this._defaultMagic(ecConfig.CHART_TYPE_PIE, ecConfig.CHART_TYPE_FUNNEL);
4456            if (this._magicType[_MAGICTYPE_STACK] || this._magicType[_MAGICTYPE_TILED]) {
4457                for (var i = 0, l = this.option.series.length; i < l; i++) {
4458                    if (this._magicType[_MAGICTYPE_STACK]) {
4459                        this.option.series[i].stack = '_ECHARTS_STACK_KENER_2014_';
4460                        chartType = _MAGICTYPE_STACK;
4461                    } else if (this._magicType[_MAGICTYPE_TILED]) {
4462                        this.option.series[i].stack = null;
4463                        chartType = _MAGICTYPE_TILED;
4464                    }
4465                    if (this._featureOption[chartType + 'Chart']) {
4466                        zrUtil.merge(this.option.series[i], this._featureOption[chartType + 'Chart'] || {}, true);
4467                    }
4468                }
4469            }
4470            return this.option;
4471        },
4472        _defaultMagic: function (cType1, cType2) {
4473            if (this._magicType[cType1] || this._magicType[cType2]) {
4474                for (var i = 0, l = this.option.series.length; i < l; i++) {
4475                    var chartType = this.option.series[i].type;
4476                    if (chartType == cType1 || chartType == cType2) {
4477                        this.option.series[i].type = this._magicType[cType1] ? cType1 : cType2;
4478                        this.option.series[i].itemStyle = zrUtil.clone(this.option.series[i].__itemStyle);
4479                        chartType = this.option.series[i].type;
4480                        if (this._featureOption[chartType + 'Chart']) {
4481                            zrUtil.merge(this.option.series[i], this._featureOption[chartType + 'Chart'] || {}, true);
4482                        }
4483                    }
4484                }
4485            }
4486        },
4487        silence: function (s) {
4488            this._isSilence = s;
4489        },
4490        resize: function () {
4491            this._resetMark();
4492            this.clear();
4493            if (this.option && this.option.toolbox && this.option.toolbox.show) {
4494                this._buildShape();
4495            }
4496            if (this._dataView) {
4497                this._dataView.resize();
4498            }
4499        },
4500        hideDataView: function () {
4501            if (this._dataView) {
4502                this._dataView.hide();
4503            }
4504        },
4505        clear: function (notMark) {
4506            if (this.zr) {
4507                this.zr.delShape(this.shapeList);
4508                this.shapeList = [];
4509                if (!notMark) {
4510                    this.zr.delShape(this._markShapeList);
4511                    this._markShapeList = [];
4512                }
4513            }
4514        },
4515        onbeforDispose: function () {
4516            if (this._dataView) {
4517                this._dataView.dispose();
4518                this._dataView = null;
4519            }
4520            this._markShapeList = null;
4521        },
4522        refresh: function (newOption) {
4523            if (newOption) {
4524                this._resetMark();
4525                this._resetZoom();
4526                newOption.toolbox = this.reformOption(newOption.toolbox);
4527                this.option = newOption;
4528                this.clear(true);
4529                if (newOption.toolbox.show) {
4530                    this._buildShape();
4531                }
4532                this.hideDataView();
4533            }
4534        }
4535    };
4536    zrUtil.inherits(Toolbox, Base);
4537    require('../component').define('toolbox', Toolbox);
4538    return Toolbox;
4539});define('echarts/component', [], function () {
4540    var self = {};
4541    var _componentLibrary = {};
4542    self.define = function (name, clazz) {
4543        _componentLibrary[name] = clazz;
4544        return self;
4545    };
4546    self.get = function (name) {
4547        return _componentLibrary[name];
4548    };
4549    return self;
4550});define('echarts/component/title', [
4551    'require',
4552    './base',
4553    'zrender/shape/Text',
4554    'zrender/shape/Rectangle',
4555    '../config',
4556    'zrender/tool/util',
4557    'zrender/tool/area',
4558    'zrender/tool/color',
4559    '../component'
4560], function (require) {
4561    var Base = require('./base');
4562    var TextShape = require('zrender/shape/Text');
4563    var RectangleShape = require('zrender/shape/Rectangle');
4564    var ecConfig = require('../config');
4565    ecConfig.title = {
4566        zlevel: 0,
4567        z: 6,
4568        show: true,
4569        text: '',
4570        subtext: '',
4571        x: 'left',
4572        y: 'top',
4573        backgroundColor: 'rgba(0,0,0,0)',
4574        borderColor: '#ccc',
4575        borderWidth: 0,
4576        padding: 5,
4577        itemGap: 5,
4578        textStyle: {
4579            fontSize: 18,
4580            fontWeight: 'bolder',
4581            color: '#333'
4582        },
4583        subtextStyle: { color: '#aaa' }
4584    };
4585    var zrUtil = require('zrender/tool/util');
4586    var zrArea = require('zrender/tool/area');
4587    var zrColor = require('zrender/tool/color');
4588    function Title(ecTheme, messageCenter, zr, option, myChart) {
4589        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
4590        this.refresh(option);
4591    }
4592    Title.prototype = {
4593        type: ecConfig.COMPONENT_TYPE_TITLE,
4594        _buildShape: function () {
4595            if (!this.titleOption.show) {
4596                return;
4597            }
4598            this._itemGroupLocation = this._getItemGroupLocation();
4599            this._buildBackground();
4600            this._buildItem();
4601            for (var i = 0, l = this.shapeList.length; i < l; i++) {
4602                this.zr.addShape(this.shapeList[i]);
4603            }
4604        },
4605        _buildItem: function () {
4606            var text = this.titleOption.text;
4607            var link = this.titleOption.link;
4608            var target = this.titleOption.target;
4609            var subtext = this.titleOption.subtext;
4610            var sublink = this.titleOption.sublink;
4611            var subtarget = this.titleOption.subtarget;
4612            var font = this.getFont(this.titleOption.textStyle);
4613            var subfont = this.getFont(this.titleOption.subtextStyle);
4614            var x = this._itemGroupLocation.x;
4615            var y = this._itemGroupLocation.y;
4616            var width = this._itemGroupLocation.width;
4617            var height = this._itemGroupLocation.height;
4618            var textShape = {
4619                zlevel: this.getZlevelBase(),
4620                z: this.getZBase(),
4621                style: {
4622                    y: y,
4623                    color: this.titleOption.textStyle.color,
4624                    text: text,
4625                    textFont: font,
4626                    textBaseline: 'top'
4627                },
4628                highlightStyle: {
4629                    color: zrColor.lift(this.titleOption.textStyle.color, 1),
4630                    brushType: 'fill'
4631                },
4632                hoverable: false
4633            };
4634            if (link) {
4635                textShape.hoverable = true;
4636                textShape.clickable = true;
4637                textShape.onclick = function () {
4638                    if (!target || target != 'self') {
4639                        window.open(link);
4640                    } else {
4641                        window.location = link;
4642                    }
4643                };
4644            }
4645            var subtextShape = {
4646                zlevel: this.getZlevelBase(),
4647                z: this.getZBase(),
4648                style: {
4649                    y: y + height,
4650                    color: this.titleOption.subtextStyle.color,
4651                    text: subtext,
4652                    textFont: subfont,
4653                    textBaseline: 'bottom'
4654                },
4655                highlightStyle: {
4656                    color: zrColor.lift(this.titleOption.subtextStyle.color, 1),
4657                    brushType: 'fill'
4658                },
4659                hoverable: false
4660            };
4661            if (sublink) {
4662                subtextShape.hoverable = true;
4663                subtextShape.clickable = true;
4664                subtextShape.onclick = function () {
4665                    if (!subtarget || subtarget != 'self') {
4666                        window.open(sublink);
4667                    } else {
4668                        window.location = sublink;
4669                    }
4670                };
4671            }
4672            switch (this.titleOption.x) {
4673            case 'center':
4674                textShape.style.x = subtextShape.style.x = x + width / 2;
4675                textShape.style.textAlign = subtextShape.style.textAlign = 'center';
4676                break;
4677            case 'left':
4678                textShape.style.x = subtextShape.style.x = x;
4679                textShape.style.textAlign = subtextShape.style.textAlign = 'left';
4680                break;
4681            case 'right':
4682                textShape.style.x = subtextShape.style.x = x + width;
4683                textShape.style.textAlign = subtextShape.style.textAlign = 'right';
4684                break;
4685            default:
4686                x = this.titleOption.x - 0;
4687                x = isNaN(x) ? 0 : x;
4688                textShape.style.x = subtextShape.style.x = x;
4689                break;
4690            }
4691            if (this.titleOption.textAlign) {
4692                textShape.style.textAlign = subtextShape.style.textAlign = this.titleOption.textAlign;
4693            }
4694            this.shapeList.push(new TextShape(textShape));
4695            subtext !== '' && this.shapeList.push(new TextShape(subtextShape));
4696        },
4697        _buildBackground: function () {
4698            var padding = this.reformCssArray(this.titleOption.padding);
4699            this.shapeList.push(new RectangleShape({
4700                zlevel: this.getZlevelBase(),
4701                z: this.getZBase(),
4702                hoverable: false,
4703                style: {
4704                    x: this._itemGroupLocation.x - padding[3],
4705                    y: this._itemGroupLocation.y - padding[0],
4706                    width: this._itemGroupLocation.width + padding[3] + padding[1],
4707                    height: this._itemGroupLocation.height + padding[0] + padding[2],
4708                    brushType: this.titleOption.borderWidth === 0 ? 'fill' : 'both',
4709                    color: this.titleOption.backgroundColor,
4710                    strokeColor: this.titleOption.borderColor,
4711                    lineWidth: this.titleOption.borderWidth
4712                }
4713            }));
4714        },
4715        _getItemGroupLocation: function () {
4716            var padding = this.reformCssArray(this.titleOption.padding);
4717            var text = this.titleOption.text;
4718            var subtext = this.titleOption.subtext;
4719            var font = this.getFont(this.titleOption.textStyle);
4720            var subfont = this.getFont(this.titleOption.subtextStyle);
4721            var totalWidth = Math.max(zrArea.getTextWidth(text, font), zrArea.getTextWidth(subtext, subfont));
4722            var totalHeight = zrArea.getTextHeight(text, font) + (subtext === '' ? 0 : this.titleOption.itemGap + zrArea.getTextHeight(subtext, subfont));
4723            var x;
4724            var zrWidth = this.zr.getWidth();
4725            switch (this.titleOption.x) {
4726            case 'center':
4727                x = Math.floor((zrWidth - totalWidth) / 2);
4728                break;
4729            case 'left':
4730                x = padding[3] + this.titleOption.borderWidth;
4731                break;
4732            case 'right':
4733                x = zrWidth - totalWidth - padding[1] - this.titleOption.borderWidth;
4734                break;
4735            default:
4736                x = this.titleOption.x - 0;
4737                x = isNaN(x) ? 0 : x;
4738                break;
4739            }
4740            var y;
4741            var zrHeight = this.zr.getHeight();
4742            switch (this.titleOption.y) {
4743            case 'top':
4744                y = padding[0] + this.titleOption.borderWidth;
4745                break;
4746            case 'bottom':
4747                y = zrHeight - totalHeight - padding[2] - this.titleOption.borderWidth;
4748                break;
4749            case 'center':
4750                y = Math.floor((zrHeight - totalHeight) / 2);
4751                break;
4752            default:
4753                y = this.titleOption.y - 0;
4754                y = isNaN(y) ? 0 : y;
4755                break;
4756            }
4757            return {
4758                x: x,
4759                y: y,
4760                width: totalWidth,
4761                height: totalHeight
4762            };
4763        },
4764        refresh: function (newOption) {
4765            if (newOption) {
4766                this.option = newOption;
4767                this.option.title = this.reformOption(this.option.title);
4768                this.titleOption = this.option.title;
4769                this.titleOption.textStyle = this.getTextStyle(this.titleOption.textStyle);
4770                this.titleOption.subtextStyle = this.getTextStyle(this.titleOption.subtextStyle);
4771            }
4772            this.clear();
4773            this._buildShape();
4774        }
4775    };
4776    zrUtil.inherits(Title, Base);
4777    require('../component').define('title', Title);
4778    return Title;
4779});define('echarts/component/tooltip', [
4780    'require',
4781    './base',
4782    '../util/shape/Cross',
4783    'zrender/shape/Line',
4784    'zrender/shape/Rectangle',
4785    '../config',
4786    '../util/ecData',
4787    'zrender/config',
4788    'zrender/tool/event',
4789    'zrender/tool/area',
4790    'zrender/tool/color',
4791    'zrender/tool/util',
4792    'zrender/shape/Base',
4793    '../component'
4794], function (require) {
4795    var Base = require('./base');
4796    var CrossShape = require('../util/shape/Cross');
4797    var LineShape = require('zrender/shape/Line');
4798    var RectangleShape = require('zrender/shape/Rectangle');
4799    var rectangleInstance = new RectangleShape({});
4800    var ecConfig = require('../config');
4801    ecConfig.tooltip = {
4802        zlevel: 1,
4803        z: 8,
4804        show: true,
4805        showContent: true,
4806        trigger: 'item',
4807        islandFormatter: '{a} <br/>{b} : {c}',
4808        showDelay: 20,
4809        hideDelay: 100,
4810        transitionDuration: 0.4,
4811        enterable: false,
4812        backgroundColor: 'rgba(0,0,0,0.7)',
4813        borderColor: '#333',
4814        borderRadius: 4,
4815        borderWidth: 0,
4816        padding: 5,
4817        axisPointer: {
4818            type: 'line',
4819            lineStyle: {
4820                color: '#48b',
4821                width: 2,
4822                type: 'solid'
4823            },
4824            crossStyle: {
4825                color: '#1e90ff',
4826                width: 1,
4827                type: 'dashed'
4828            },
4829            shadowStyle: {
4830                color: 'rgba(150,150,150,0.3)',
4831                width: 'auto',
4832                type: 'default'
4833            }
4834        },
4835        textStyle: { color: '#fff' }
4836    };
4837    var ecData = require('../util/ecData');
4838    var zrConfig = require('zrender/config');
4839    var zrEvent = require('zrender/tool/event');
4840    var zrArea = require('zrender/tool/area');
4841    var zrColor = require('zrender/tool/color');
4842    var zrUtil = require('zrender/tool/util');
4843    var zrShapeBase = require('zrender/shape/Base');
4844    function Tooltip(ecTheme, messageCenter, zr, option, myChart) {
4845        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
4846        this.dom = myChart.dom;
4847        var self = this;
4848        self._onmousemove = function (param) {
4849            return self.__onmousemove(param);
4850        };
4851        self._onglobalout = function (param) {
4852            return self.__onglobalout(param);
4853        };
4854        this.zr.on(zrConfig.EVENT.MOUSEMOVE, self._onmousemove);
4855        this.zr.on(zrConfig.EVENT.GLOBALOUT, self._onglobalout);
4856        self._hide = function (param) {
4857            return self.__hide(param);
4858        };
4859        self._tryShow = function (param) {
4860            return self.__tryShow(param);
4861        };
4862        self._refixed = function (param) {
4863            return self.__refixed(param);
4864        };
4865        self._setContent = function (ticket, res) {
4866            return self.__setContent(ticket, res);
4867        };
4868        this._tDom = this._tDom || document.createElement('div');
4869        this._tDom.onselectstart = function () {
4870            return false;
4871        };
4872        this._tDom.onmouseover = function () {
4873            self._mousein = true;
4874        };
4875        this._tDom.onmouseout = function () {
4876            self._mousein = false;
4877        };
4878        this._tDom.className = 'echarts-tooltip';
4879        this._tDom.style.position = 'absolute';
4880        this.hasAppend = false;
4881        this._axisLineShape && this.zr.delShape(this._axisLineShape.id);
4882        this._axisLineShape = new LineShape({
4883            zlevel: this.getZlevelBase(),
4884            z: this.getZBase(),
4885            invisible: true,
4886            hoverable: false
4887        });
4888        this.shapeList.push(this._axisLineShape);
4889        this.zr.addShape(this._axisLineShape);
4890        this._axisShadowShape && this.zr.delShape(this._axisShadowShape.id);
4891        this._axisShadowShape = new LineShape({
4892            zlevel: this.getZlevelBase(),
4893            z: 1,
4894            invisible: true,
4895            hoverable: false
4896        });
4897        this.shapeList.push(this._axisShadowShape);
4898        this.zr.addShape(this._axisShadowShape);
4899        this._axisCrossShape && this.zr.delShape(this._axisCrossShape.id);
4900        this._axisCrossShape = new CrossShape({
4901            zlevel: this.getZlevelBase(),
4902            z: this.getZBase(),
4903            invisible: true,
4904            hoverable: false
4905        });
4906        this.shapeList.push(this._axisCrossShape);
4907        this.zr.addShape(this._axisCrossShape);
4908        this.showing = false;
4909        this.refresh(option);
4910    }
4911    Tooltip.prototype = {
4912        type: ecConfig.COMPONENT_TYPE_TOOLTIP,
4913        _gCssText: 'position:absolute;display:block;border-style:solid;white-space:nowrap;',
4914        _style: function (opt) {
4915            if (!opt) {
4916                return '';
4917            }
4918            var cssText = [];
4919            if (opt.transitionDuration) {
4920                var transitionText = 'left ' + opt.transitionDuration + 's,' + 'top ' + opt.transitionDuration + 's';
4921                cssText.push('transition:' + transitionText);
4922                cssText.push('-moz-transition:' + transitionText);
4923                cssText.push('-webkit-transition:' + transitionText);
4924                cssText.push('-o-transition:' + transitionText);
4925            }
4926            if (opt.backgroundColor) {
4927                cssText.push('background-Color:' + zrColor.toHex(opt.backgroundColor));
4928                cssText.push('filter:alpha(opacity=70)');
4929                cssText.push('background-Color:' + opt.backgroundColor);
4930            }
4931            if (opt.borderWidth != null) {
4932                cssText.push('border-width:' + opt.borderWidth + 'px');
4933            }
4934            if (opt.borderColor != null) {
4935                cssText.push('border-color:' + opt.borderColor);
4936            }
4937            if (opt.borderRadius != null) {
4938                cssText.push('border-radius:' + opt.borderRadius + 'px');
4939                cssText.push('-moz-border-radius:' + opt.borderRadius + 'px');
4940                cssText.push('-webkit-border-radius:' + opt.borderRadius + 'px');
4941                cssText.push('-o-border-radius:' + opt.borderRadius + 'px');
4942            }
4943            var textStyle = opt.textStyle;
4944            if (textStyle) {
4945                textStyle.color && cssText.push('color:' + textStyle.color);
4946                textStyle.decoration && cssText.push('text-decoration:' + textStyle.decoration);
4947                textStyle.align && cssText.push('text-align:' + textStyle.align);
4948                textStyle.fontFamily && cssText.push('font-family:' 
4948+ textStyle.fontFamily);
4949                textStyle.fontSize && cssText.push('font-size:' + textStyle.fontSize + 'px');
4950                textStyle.fontSize && cssText.push('line-height:' + Math.round(textStyle.fontSize * 3 / 2) + 'px');
4951                textStyle.fontStyle && cssText.push('font-style:' + textStyle.fontStyle);
4952                textStyle.fontWeight && cssText.push('font-weight:' + textStyle.fontWeight);
4953            }
4954            var padding = opt.padding;
4955            if (padding != null) {
4956                padding = this.reformCssArray(padding);
4957                cssText.push('padding:' + padding[0] + 'px ' + padding[1] + 'px ' + padding[2] + 'px ' + padding[3] + 'px');
4958            }
4959            cssText = cssText.join(';') + ';';
4960            return cssText;
4961        },
4962        __hide: function () {
4963            this._lastDataIndex = -1;
4964            this._lastSeriesIndex = -1;
4965            this._lastItemTriggerId = -1;
4966            if (this._tDom) {
4967                this._tDom.style.display = 'none';
4968            }
4969            var needRefresh = false;
4970            if (!this._axisLineShape.invisible) {
4971                this._axisLineShape.invisible = true;
4972                this.zr.modShape(this._axisLineShape.id);
4973                needRefresh = true;
4974            }
4975            if (!this._axisShadowShape.invisible) {
4976                this._axisShadowShape.invisible = true;
4977                this.zr.modShape(this._axisShadowShape.id);
4978                needRefresh = true;
4979            }
4980            if (!this._axisCrossShape.invisible) {
4981                this._axisCrossShape.invisible = true;
4982                this.zr.modShape(this._axisCrossShape.id);
4983                needRefresh = true;
4984            }
4985            if (this._lastTipShape && this._lastTipShape.tipShape.length > 0) {
4986                this.zr.delShape(this._lastTipShape.tipShape);
4987                this._lastTipShape = false;
4988                this.shapeList.length = 2;
4989            }
4990            needRefresh && this.zr.refreshNextFrame();
4991            this.showing = false;
4992        },
4993        _show: function (position, x, y, specialCssText) {
4994            var domHeight = this._tDom.offsetHeight;
4995            var domWidth = this._tDom.offsetWidth;
4996            if (position) {
4997                if (typeof position === 'function') {
4998                    position = position([
4999                        x,
5000                        y
5001                    ]);
5002                }
5003                if (position instanceof Array) {
5004                    x = position[0];
5005                    y = position[1];
5006                }
5007            }
5008            if (x + domWidth > this._zrWidth) {
5009                x -= domWidth + 40;
5010            }
5011            if (y + domHeight > this._zrHeight) {
5012                y -= domHeight - 20;
5013            }
5014            if (y < 20) {
5015                y = 0;
5016            }
5017            this._tDom.style.cssText = this._gCssText + this._defaultCssText + (specialCssText ? specialCssText : '') + 'left:' + x + 'px;top:' + y + 'px;';
5018            if (domHeight < 10 || domWidth < 10) {
5019                setTimeout(this._refixed, 20);
5020            }
5021            this.showing = true;
5022        },
5023        __refixed: function () {
5024            if (this._tDom) {
5025                var cssText = '';
5026                var domHeight = this._tDom.offsetHeight;
5027                var domWidth = this._tDom.offsetWidth;
5028                if (this._tDom.offsetLeft + domWidth > this._zrWidth) {
5029                    cssText += 'left:' + (this._zrWidth - domWidth - 20) + 'px;';
5030                }
5031                if (this._tDom.offsetTop + domHeight > this._zrHeight) {
5032                    cssText += 'top:' + (this._zrHeight - domHeight - 10) + 'px;';
5033                }
5034                if (cssText !== '') {
5035                    this._tDom.style.cssText += cssText;
5036                }
5037            }
5038        },
5039        __tryShow: function () {
5040            var needShow;
5041            var trigger;
5042            if (!this._curTarget) {
5043                this._findPolarTrigger() || this._findAxisTrigger();
5044            } else {
5045                if (this._curTarget._type === 'island' && this.option.tooltip.show) {
5046                    this._showItemTrigger();
5047                    return;
5048                }
5049                var serie = ecData.get(this._curTarget, 'series');
5050                var data = ecData.get(this._curTarget, 'data');
5051                needShow = this.deepQuery([
5052                    data,
5053                    serie,
5054                    this.option
5055                ], 'tooltip.show');
5056                if (serie == null || data == null || !needShow) {
5057                    clearTimeout(this._hidingTicket);
5058                    clearTimeout(this._showingTicket);
5059                    this._hidingTicket = setTimeout(this._hide, this._hideDelay);
5060                } else {
5061                    trigger = this.deepQuery([
5062                        data,
5063                        serie,
5064                        this.option
5065                    ], 'tooltip.trigger');
5066                    trigger === 'axis' ? this._showAxisTrigger(serie.xAxisIndex, serie.yAxisIndex, ecData.get(this._curTarget, 'dataIndex')) : this._showItemTrigger();
5067                }
5068            }
5069        },
5070        _findAxisTrigger: function () {
5071            if (!this.component.xAxis || !this.component.yAxis) {
5072                this._hidingTicket = setTimeout(this._hide, this._hideDelay);
5073                return;
5074            }
5075            var series = this.option.series;
5076            var xAxisIndex;
5077            var yAxisIndex;
5078            for (var i = 0, l = series.length; i < l; i++) {
5079                if (this.deepQuery([
5080                        series[i],
5081                        this.option
5082                    ], 'tooltip.trigger') === 'axis') {
5083                    xAxisIndex = series[i].xAxisIndex || 0;
5084                    yAxisIndex = series[i].yAxisIndex || 0;
5085                    if (this.component.xAxis.getAxis(xAxisIndex) && this.component.xAxis.getAxis(xAxisIndex).type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY) {
5086                        this._showAxisTrigger(xAxisIndex, yAxisIndex, this._getNearestDataIndex('x', this.component.xAxis.getAxis(xAxisIndex)));
5087                        return;
5088                    } else if (this.component.yAxis.getAxis(yAxisIndex) && this.component.yAxis.getAxis(yAxisIndex).type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY) {
5089                        this._showAxisTrigger(xAxisIndex, yAxisIndex, this._getNearestDataIndex('y', this.component.yAxis.getAxis(yAxisIndex)));
5090                        return;
5091                    } else {
5092                        this._showAxisTrigger(xAxisIndex, yAxisIndex, -1);
5093                        return;
5094                    }
5095                }
5096            }
5097            if (this.option.tooltip.axisPointer.type === 'cross') {
5098                this._showAxisTrigger(-1, -1, -1);
5099            }
5100        },
5101        _findPolarTrigger: function () {
5102            if (!this.component.polar) {
5103                return false;
5104            }
5105            var x = zrEvent.getX(this._event);
5106            var y = zrEvent.getY(this._event);
5107            var polarIndex = this.component.polar.getNearestIndex([
5108                x,
5109                y
5110            ]);
5111            var valueIndex;
5112            if (polarIndex) {
5113                valueIndex = polarIndex.valueIndex;
5114                polarIndex = polarIndex.polarIndex;
5115            } else {
5116                polarIndex = -1;
5117            }
5118            if (polarIndex != -1) {
5119                return this._showPolarTrigger(polarIndex, valueIndex);
5120            }
5121            return false;
5122        },
5123        _getNearestDataIndex: function (direction, categoryAxis) {
5124            var dataIndex = -1;
5125            var x = zrEvent.getX(this._event);
5126            var y = zrEvent.getY(this._event);
5127            if (direction === 'x') {
5128                var left;
5129                var right;
5130                var xEnd = this.component.grid.getXend();
5131                var curCoord = categoryAxis.getCoordByIndex(dataIndex);
5132                while (curCoord < xEnd) {
5133                    right = curCoord;
5134                    if (curCoord <= x) {
5135                        left = curCoord;
5136                    } else {
5137                        break;
5138                    }
5139                    curCoord = categoryAxis.getCoordByIndex(++dataIndex);
5140                }
5141                if (dataIndex <= 0) {
5142                    dataIndex = 0;
5143                } else if (x - left <= right - x) {
5144                    dataIndex -= 1;
5145                } else {
5146                    if (categoryAxis.getNameByIndex(dataIndex) == null) {
5147                        dataIndex -= 1;
5148                    }
5149                }
5150                return dataIndex;
5151            } else {
5152                var top;
5153                var bottom;
5154                var yStart = this.component.grid.getY();
5155                var curCoord = categoryAxis.getCoordByIndex(dataIndex);
5156                while (curCoord > yStart) {
5157                    top = curCoord;
5158                    if (curCoord >= y) {
5159                        bottom = curCoord;
5160                    } else {
5161                        break;
5162                    }
5163                    curCoord = categoryAxis.getCoordByIndex(++dataIndex);
5164                }
5165                if (dataIndex <= 0) {
5166                    dataIndex = 0;
5167                } else if (y - top >= bottom - y) {
5168                    dataIndex -= 1;
5169                } else {
5170                    if (categoryAxis.getNameByIndex(dataIndex) == null) {
5171                        dataIndex -= 1;
5172                    }
5173                }
5174                return dataIndex;
5175            }
5176            return -1;
5177        },
5178        _showAxisTrigger: function (xAxisIndex, yAxisIndex, dataIndex) {
5179            !this._event.connectTrigger && this.messageCenter.dispatch(ecConfig.EVENT.TOOLTIP_IN_GRID, this._event, null, this.myChart);
5180            if (this.component.xAxis == null || this.component.yAxis == null || xAxisIndex == null || yAxisIndex == null) {
5181                clearTimeout(this._hidingTicket);
5182                clearTimeout(this._showingTicket);
5183                this._hidingTicket = setTimeout(this._hide, this._hideDelay);
5184                return;
5185            }
5186            var series = this.option.series;
5187            var seriesArray = [];
5188            var seriesIndex = [];
5189            var categoryAxis;
5190            var formatter;
5191            var position;
5192            var showContent;
5193            var specialCssText = '';
5194            if (this.option.tooltip.trigger === 'axis') {
5195                if (!this.option.tooltip.show) {
5196                    return;
5197                }
5198                formatter = this.option.tooltip.formatter;
5199                position = this.option.tooltip.position;
5200            }
5201            var axisLayout = xAxisIndex != -1 && this.component.xAxis.getAxis(xAxisIndex).type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY ? 'xAxis' : yAxisIndex != -1 && this.component.yAxis.getAxis(yAxisIndex).type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY ? 'yAxis' : false;
5202            var x;
5203            var y;
5204            if (axisLayout) {
5205                var axisIndex = axisLayout == 'xAxis' ? xAxisIndex : yAxisIndex;
5206                categoryAxis = this.component[axisLayout].getAxis(axisIndex);
5207                for (var i = 0, l = series.length; i < l; i++) {
5208                    if (!this._isSelected(series[i].name)) {
5209                        continue;
5210                    }
5211                    if (series[i][axisLayout + 'Index'] === axisIndex && this.deepQuery([
5212                            series[i],
5213                            this.option
5214                        ], 'tooltip.trigger') === 'axis') {
5215                        showContent = this.query(series[i], 'tooltip.showContent') || showContent;
5216                        formatter = this.query(series[i], 'tooltip.formatter') || formatter;
5217                        position = this.query(series[i], 'tooltip.position') || position;
5218                        specialCssText += this._style(this.query(series[i], 'tooltip'));
5219                        if (series[i].stack != null && axisLayout == 'xAxis') {
5220                            seriesArray.unshift(series[i]);
5221                            seriesIndex.unshift(i);
5222                        } else {
5223                            seriesArray.push(series[i]);
5224                            seriesIndex.push(i);
5225                        }
5226                    }
5227                }
5228                this.messageCenter.dispatch(ecConfig.EVENT.TOOLTIP_HOVER, this._event, {
5229                    seriesIndex: seriesIndex,
5230                    dataIndex: dataIndex
5231                }, this.myChart);
5232                var rect;
5233                if (axisLayout == 'xAxis') {
5234                    x = this.subPixelOptimize(categoryAxis.getCoordByIndex(dataIndex), this._axisLineWi
5234dth);
5235                    y = zrEvent.getY(this._event);
5236                    rect = [
5237                        x,
5238                        this.component.grid.getY(),
5239                        x,
5240                        this.component.grid.getYend()
5241                    ];
5242                } else {
5243                    x = zrEvent.getX(this._event);
5244                    y = this.subPixelOptimize(categoryAxis.getCoordByIndex(dataIndex), this._axisLineWidth);
5245                    rect = [
5246                        this.component.grid.getX(),
5247                        y,
5248                        this.component.grid.getXend(),
5249                        y
5250                    ];
5251                }
5252                this._styleAxisPointer(seriesArray, rect[0], rect[1], rect[2], rect[3], categoryAxis.getGap(), x, y);
5253            } else {
5254                x = zrEvent.getX(this._event);
5255                y = zrEvent.getY(this._event);
5256                this._styleAxisPointer(series, this.component.grid.getX(), y, this.component.grid.getXend(), y, 0, x, y);
5257                if (dataIndex >= 0) {
5258                    this._showItemTrigger(true);
5259                } else {
5260                    clearTimeout(this._hidingTicket);
5261                    clearTimeout(this._showingTicket);
5262                    this._tDom.style.display = 'none';
5263                }
5264            }
5265            if (seriesArray.length > 0) {
5266                this._lastItemTriggerId = -1;
5267                if (this._lastDataIndex != dataIndex || this._lastSeriesIndex != seriesIndex[0]) {
5268                    this._lastDataIndex = dataIndex;
5269                    this._lastSeriesIndex = seriesIndex[0];
5270                    var data;
5271                    var value;
5272                    if (typeof formatter === 'function') {
5273                        var params = [];
5274                        for (var i = 0, l = seriesArray.length; i < l; i++) {
5275                            data = seriesArray[i].data[dataIndex];
5276                            value = this.getDataFromOption(data, '-');
5277                            params.push({
5278                                seriesIndex: seriesIndex[i],
5279                                seriesName: seriesArray[i].name || '',
5280                                series: seriesArray[i],
5281                                dataIndex: dataIndex,
5282                                data: data,
5283                                name: categoryAxis.getNameByIndex(dataIndex),
5284                                value: value,
5285                                0: seriesArray[i].name || '',
5286                                1: categoryAxis.getNameByIndex(dataIndex),
5287                                2: value,
5288                                3: data
5289                            });
5290                        }
5291                        this._curTicket = 'axis:' + dataIndex;
5292                        this._tDom.innerHTML = formatter.call(this.myChart, params, this._curTicket, this._setContent);
5293                    } else if (typeof formatter === 'string') {
5294                        this._curTicket = NaN;
5295                        formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}');
5296                        for (var i = 0, l = seriesArray.length; i < l; i++) {
5297                            formatter = formatter.replace('{a' + i + '}', this._encodeHTML(seriesArray[i].name || ''));
5298                            formatter = formatter.replace('{b' + i + '}', this._encodeHTML(categoryAxis.getNameByIndex(dataIndex)));
5299                            data = seriesArray[i].data[dataIndex];
5300                            data = this.getDataFromOption(data, '-');
5301                            formatter = formatter.replace('{c' + i + '}', data instanceof Array ? data : this.numAddCommas(data));
5302                        }
5303                        this._tDom.innerHTML = formatter;
5304                    } else {
5305                        this._curTicket = NaN;
5306                        formatter = this._encodeHTML(categoryAxis.getNameByIndex(dataIndex));
5307                        for (var i = 0, l = seriesArray.length; i < l; i++) {
5308                            formatter += '<br/>' + this._encodeHTML(seriesArray[i].name || '') + ' : ';
5309                            data = seriesArray[i].data[dataIndex];
5310                            data = this.getDataFromOption(data, '-');
5311                            formatter += data instanceof Array ? data : this.numAddCommas(data);
5312                        }
5313                        this._tDom.innerHTML = formatter;
5314                    }
5315                }
5316                if (showContent === false || !this.option.tooltip.showContent) {
5317                    return;
5318                }
5319                if (!this.hasAppend) {
5320                    this._tDom.style.left = this._zrWidth / 2 + 'px';
5321                    this._tDom.style.top = this._zrHeight / 2 + 'px';
5322                    this.dom.firstChild.appendChild(this._tDom);
5323                    this.hasAppend = true;
5324                }
5325                this._show(position, x + 10, y + 10, specialCssText);
5326            }
5327        },
5328        _showPolarTrigger: function (polarIndex, dataIndex) {
5329            if (this.component.polar == null || polarIndex == null || dataIndex == null || dataIndex < 0) {
5330                return false;
5331            }
5332            var series = this.option.series;
5333            var seriesArray = [];
5334            var seriesIndex = [];
5335            var formatter;
5336            var position;
5337            var showContent;
5338            var specialCssText = '';
5339            if (this.option.tooltip.trigger === 'axis') {
5340                if (!this.option.tooltip.show) {
5341                    return false;
5342                }
5343                formatter = this.option.tooltip.formatter;
5344                position = this.option.tooltip.position;
5345            }
5346            var indicatorName = this.option.polar[polarIndex].indicator[dataIndex].text;
5347            for (var i = 0, l = series.length; i < l; i++) {
5348                if (!this._isSelected(series[i].name)) {
5349                    continue;
5350                }
5351                if (series[i].polarIndex === polarIndex && this.deepQuery([
5352                        series[i],
5353                        this.option
5354                    ], 'tooltip.trigger') === 'axis') {
5355                    showContent = this.query(series[i], 'tooltip.showContent') || showContent;
5356                    formatter = this.query(series[i], 'tooltip.formatter') || formatter;
5357                    position = this.query(series[i], 'tooltip.position') || position;
5358                    specialCssText += this._style(this.query(series[i], 'tooltip'));
5359                    seriesArray.push(series[i]);
5360                    seriesIndex.push(i);
5361                }
5362            }
5363            if (seriesArray.length > 0) {
5364                var polarData;
5365                var data;
5366                var value;
5367                var params = [];
5368                for (var i = 0, l = seriesArray.length; i < l; i++) {
5369                    polarData = seriesArray[i].data;
5370                    for (var j = 0, k = polarData.length; j < k; j++) {
5371                        data = polarData[j];
5372                        if (!this._isSelected(data.name)) {
5373                            continue;
5374                        }
5375                        data = data != null ? data : {
5376                            name: '',
5377                            value: { dataIndex: '-' }
5378                        };
5379                        value = this.getDataFromOption(data.value[dataIndex]);
5380                        params.push({
5381                            seriesIndex: seriesIndex[i],
5382                            seriesName: seriesArray[i].name || '',
5383                            series: seriesArray[i],
5384                            dataIndex: dataIndex,
5385                            data: data,
5386                            name: data.name,
5387                            indicator: indicatorName,
5388                            value: value,
5389                            0: seriesArray[i].name || '',
5390                            1: data.name,
5391                            2: value,
5392                            3: indicatorName
5393                        });
5394                    }
5395                }
5396                if (params.length <= 0) {
5397                    return;
5398                }
5399                this._lastItemTriggerId = -1;
5400                if (this._lastDataIndex != dataIndex || this._lastSeriesIndex != seriesIndex[0]) {
5401                    this._lastDataIndex = dataIndex;
5402                    this._lastSeriesIndex = seriesIndex[0];
5403                    if (typeof formatter === 'function') {
5404                        this._curTicket = 'axis:' + dataIndex;
5405                        this._tDom.innerHTML = formatter.call(this.myChart, params, this._curTicket, this._setContent);
5406                    } else if (typeof formatter === 'string') {
5407                        formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}').replace('{d}', '{d0}');
5408                        for (var i = 0, l = params.length; i < l; i++) {
5409                            formatter = formatter.replace('{a' + i + '}', this._encodeHTML(params[i].seriesName));
5410                            formatter = formatter.replace('{b' + i + '}', this._encodeHTML(params[i].name));
5411                            formatter = formatter.replace('{c' + i + '}', this.numAddCommas(params[i].value));
5412                            formatter = formatter.replace('{d' + i + '}', this._encodeHTML(params[i].indicator));
5413                        }
5414                        this._tDom.innerHTML = formatter;
5415                    } else {
5416                        formatter = this._encodeHTML(params[0].name) + '<br/>' + this._encodeHTML(params[0].indicator) + ' : ' + this.numAddCommas(params[0].value);
5417                        for (var i = 1, l = params.length; i < l; i++) {
5418                            formatter += '<br/>' + this._encodeHTML(params[i].name) + '<br/>';
5419                            formatter += this._encodeHTML(params[i].indicator) + ' : ' + this.numAddCommas(params[i].value);
5420                        }
5421                        this._tDom.innerHTML = formatter;
5422                    }
5423                }
5424                if (showContent === false || !this.option.tooltip.showContent) {
5425                    return;
5426                }
5427                if (!this.hasAppend) {
5428                    this._tDom.style.left = this._zrWidth / 2 + 'px';
5429                    this._tDom.style.top = this._zrHeight / 2 + 'px';
5430                    this.dom.firstChild.appendChild(this._tDom);
5431                    this.hasAppend = true;
5432                }
5433                this._show(position, zrEvent.getX(this._event), zrEvent.getY(this._event), specialCssText);
5434                return true;
5435            }
5436        },
5437        _showItemTrigger: function (axisTrigger) {
5438            if (!this._curTarget) {
5439                return;
5440            }
5441            var serie = ecData.get(this._curTarget, 'series');
5442            var seriesIndex = ecData.get(this._curTarget, 'seriesIndex');
5443            var data = ecData.get(this._curTarget, 'data');
5444            var dataIndex = ecData.get(this._curTarget, 'dataIndex');
5445            var name = ecData.get(this._curTarget, 'name');
5446            var value = ecData.get(this._curTarget, 'value');
5447            var special = ecData.get(this._curTarget, 'special');
5448            var special2 = ecData.get(this._curTarget, 'special2');
5449            var queryTarget = [
5450                data,
5451                serie,
5452                this.option
5453            ];
5454            var formatter;
5455            var position;
5456            var showContent;
5457            var specialCssText = '';
5458            if (this._curTarget._type != 'island') {
5459                var trigger = axisTrigger ? 'axis' : 'item';
5460                if (this.option.tooltip.trigger === trigger) {
5461                    formatter = this.option.tooltip.formatter;
5462                    position = this.option.tooltip.position;
5463                }
5464                if (this.query(serie, 'tooltip.trigger') === trigger) {
5465                    showContent = this.query(serie, 'tooltip.showContent') || showContent;
5466                    formatter = this.query(serie, 'tooltip.formatter') || formatter;
5467                    position = this.query(serie, 'tooltip.position') || position;
5468                    specialCssText += this._style(this.query(serie, 'tooltip'));
5469                }
5470                showContent = this.query(data, 'tooltip.showContent') || showContent;
5471                formatter = this.query(data, 'tooltip.formatter') || formatter;
5472                position = this.query(data, 'tooltip.position') || position;
5473                specialCssText += this._style(this.query(data, 'tooltip'));
5474            } else {
5475                this._lastItemTriggerId = NaN;
5476                showContent = this.deepQuery(queryTarget, 'tooltip.showContent');
5477                formatter = this.deepQuery(queryTarget, 'tooltip.islandFormatter');
5478                position = this.deepQuery(queryTarget, 'tooltip.islandPosition');
5479            }
5480            this._lastDataIndex = -1;
5481            this._lastSeriesIndex = -1;
5482            if (this._lastItemTriggerId !== this._curTarget.id) {
5483                this._lastItemTriggerId = this._curTarget.id;
5484                if (typeof formatter === 'function') {
5485                    this._curTicket = (serie.name || '') + ':' + dataIndex;
5486                    this._tDom.innerHTML = formatter.call(this.myChart, {
5487                        seriesIndex: seriesIndex,
5488                        seriesName: serie.name || '',
5489                        series: serie,
5490                        dataIndex: dataIndex,
5491                        data: data,
5492                        name: name,
5493                        value: value,
5494                        percent: special,
5495                        indicator: special,
5496                        value2: special2,
5497                        indicator2: special2,
5498                        0: serie.name || '',
5499                        1: name,
5500                        2: value,
5501                        3: special,
5502                        4: special2,
5503                        5: data,
5504                        6: seriesIndex,
5505                        7: dataIndex
5506                    }, this._curTicket, this._setContent);
5507                } else if (typeof formatter === 'string') {
5508                    this._curTicket = NaN;
5509                    formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}');
5510                    formatter = formatter.replace('{a0}', this._encodeHTML(serie.name || '')).replace('{b0}', this._encodeHTML(name)).replace('{c0}', value instanceof Array ? value : this.numAddCommas(value));
5511                    formatter = formatter.replace('{d}', '{d0}').replace('{d0}', special || '');
5512                    formatter = formatter.replace('{e}', '{e0}').replace('{e0}', ecData.get(this._curTarget, 'special2') || '');
5513                    this._tDom.innerHTML = formatter;
5514                } else {
5515                    this._curTicket = NaN;
5516                    if (serie.type === ecConfig.CHART_TYPE_RADAR && special) {
5517                        this._tDom.innerHTML = this._itemFormatter.radar.call(this, serie, name, value, special);
5518                    } else if (serie.type === ecConfig.CHART_TYPE_EVENTRIVER) {
5519                        this._tDom.innerHTML = this._itemFormatter.eventRiver.call(this, serie, name, value, data);
5520                    } else {
5521                        this._tDom.innerHTML = '' + (serie.name != null ? this._encodeHTML(serie.name) + '<br/>' : '') + (name === '' ? '' : this._encodeHTML(name) + ' : ') + (value instanceof Array ? value : this.numAddCommas(value));
5522                    }
5523                }
5524            }
5525            var x = zrEvent.getX(this._event);
5526            var y = zrEvent.getY(this._event);
5527            if (this.deepQuery(queryTarget, 'tooltip.axisPointer.show') && this.component.grid) {
5528                this._styleAxisPointer([serie], this.component.grid.getX(), y, this.component.grid.getXend(), y, 0, x, y);
5529            } else {
5530                this._hide();
5531            }
5532            if (showContent === false || !this.option.tooltip.showContent) {
5533                return;
5534            }
5535            if (!this.hasAppend) {
5536                this._tDom.style.left = this._zrWidth / 2 + 'px';
5537                this._tDom.style.top = this._zrHeight / 2 + 'px';
5538                this.dom.firstChild.appendChild(this._tDom);
5539                this.hasAppend = true;
5540            }
5541            this._show(position, x + 20, y - 20, specialCssText);
5542        },
5543        _itemFormatter: {
5544            radar: function (serie, name, value, indicator) {
5545                var html = '';
5546                html += this._encodeHTML(name === '' ? serie.name || '' : name);
5547                html += html === '' ? '' : '<br />';
5548                for (var i = 0; i < indicator.length; i++) {
5549                    html += this._encodeHTML(indicator[i].text) + ' : ' + this.numAddCommas(value[i]) + '<br />';
5550                }
5551                return html;
5552            },
5553            chord: function (serie, name, value, special, special2) {
5554                if (special2 == null) {
5555                    return this._encodeHTML(name) + ' (' + this.numAddCommas(value) + ')';
5556                } else {
5557                    var name1 = this._encodeHTML(name);
5558                    var name2 = this._encodeHTML(special);
5559                    return '' + (serie.name != null ? this._encodeHTML(serie.name) + '<br/>' : '') + name1 + ' -> ' + name2 + ' (' + this.numAddCommas(value) + ')' + '<br />' + name2 + ' -> ' + name1 + ' (' + this.numAddCommas(special2) + ')';
5560                }
5561            },
5562            eventRiver: function (serie, name, value, data) {
5563                var html = '';
5564                html += this._encodeHTML(serie.name === '' ? '' : serie.name + ' : ');
5565                html += this._encodeHTML(name);
5566                html += html === '' ? '' : '<br />';
5567                data = data.evolution;
5568                for (var i = 0, l = data.length; i < l; i++) {
5569                    html += '<div style="padding-top:5px;">';
5570                    if (!data[i].detail) {
5571                        continue;
5572                    }
5573                    if (data[i].detail.img) {
5574                        html += '<img src="' + data[i].detail.img + '" style="float:left;width:40px;height:40px;">';
5575                    }
5576                    html += '<div style="margin-left:45px;">' + data[i].time + '<br/>';
5577                    html += '<a href="' + data[i].detail.link + '" target="_blank">';
5578                    html += data[i].detail.text + '</a></div>';
5579                    html += '</div>';
5580                }
5581                return html;
5582            }
5583        },
5584        _styleAxisPointer: function (seriesArray, xStart, yStart, xEnd, yEnd, gap, x, y) {
5585            if (seriesArray.length > 0) {
5586                var queryTarget;
5587                var curType;
5588                var axisPointer = this.option.tooltip.axisPointer;
5589                var pointType = axisPointer.type;
5590                var style = {
5591                    line: {},
5592                    cross: {},
5593                    shadow: {}
5594                };
5595                for (var pType in style) {
5596                    style[pType].color = axisPointer[pType + 'Style'].color;
5597                    style[pType].width = axisPointer[pType + 'Style'].width;
5598                    style[pType].type = axisPointer[pType + 'Style'].type;
5599                }
5600                for (var i = 0, l = seriesArray.length; i < l; i++) {
5601                    queryTarget = seriesArray[i];
5602                    curType = this.query(queryTarget, 'tooltip.axisPointer.type');
5603                    pointType = curType || pointType;
5604                    if (curType) {
5605                        style[curType].color = this.query(queryTarget, 'tooltip.axisPointer.' + curType + 'Style.color') || style[curType].color;
5606                        style[curType].width = this.query(queryTarget, 'tooltip.axisPointer.' + curType + 'Style.width') || style[curType].width;
5607                        style[curType].type = this.query(queryTarget, 'tooltip.axisPointer.' + curType + 'Style.type') || style[curType].type;
5608                    }
5609                }
5610                if (pointType === 'line') {
5611                    var lineWidth = style.line.width;
5612                    var isVertical = xStart == xEnd;
5613                    this._axisLineShape.style = {
5614                        xStart: isVertical ? this.subPixelOptimize(xStart, lineWidth) : xStart,
5615                        yStart: isVertical ? yStart : this.subPixelOptimize(yStart, lineWidth),
5616                        xEnd: isVertical ? this.subPixelOptimize(xEnd, lineWidth) : xEnd,
5617                        yEnd: isVertical ? yEnd : this.subPixelOptimize(yEnd, lineWidth),
5618                        strokeColor: style.line.color,
5619                        lineWidth: lineWidth,
5620                        lineType: style.line.type
5621                    };
5622                    this._axisLineShape.invisible = false;
5623                    this.zr.modShape(this._axisLineShape.id);
5624                } else if (pointType === 'cross') {
5625                    var crossWidth = style.cross.width;
5626                    this._axisCrossShape.style = {
5627                        brushType: 'stroke',
5628                        rect: this.component.grid.getArea(),
5629                        x: this.subPixelOptimize(x, crossWidth),
5630                        y: this.subPixelOptimize(y, crossWidth),
5631                        text: ('( ' + this.component.xAxis.getAxis(0).getValueFromCoord(x) + ' , ' + this.component.yAxis.getAxis(0).getValueFromCoord(y) + ' )').replace('  , ', ' ').replace(' ,  ', ' '),
5632                        textPosition: 'specific',
5633                        strokeColor: style.cross.color,
5634                        lineWidth: crossWidth,
5635                        lineType: style.cross.type
5636                    };
5637                    if (this.component.grid.getXend() - x > 100) {
5638                        this._axisCrossShape.style.textAlign = 'left';
5639                        this._axisCrossShape.style.textX = x + 10;
5640                    } else {
5641                        this._axisCrossShape.style.textAlign = 'right';
5642                        this._axisCrossShape.style.textX = x - 10;
5643                    }
5644                    if (y - this.component.grid.getY() > 50) {
5645                        this._axisCrossShape.style.textBaseline = 'bottom';
5646                        this._axisCrossShape.style.textY = y - 10;
5647                    } else {
5648                        this._axisCrossShape.style.textBaseline = 'top';
5649                        this._axisCrossShape.style.textY = y + 10;
5650                    }
5651                    this._axisCrossShape.invisible = false;
5652                    this.zr.modShape(this._axisCrossShape.id);
5653                } else if (pointType === 'shadow') {
5654                    if (style.shadow.width == null || style.shadow.width === 'auto' || isNaN(style.shadow.width)) {
5655                        style.shadow.width = gap;
5656                    }
5657                    if (xStart === xEnd) {
5658                        if (Math.abs(this.component.grid.getX() - xStart) < 2) {
5659                            style.shadow.width /= 2;
5660                            xStart = xEnd = xEnd + style.shadow.width / 2;
5661                        } else if (Math.abs(this.component.grid.getXend() - xStart) < 2) {
5662                            style.shadow.width /= 2;
5663                            xStart = xEnd = xEnd - style.shadow.width / 2;
5664                        }
5665                    } else if (yStart === yEnd) {
5666                        if (Math.abs(this.component.grid.getY() - yStart) < 2) {
5667                            style.shadow.width /= 2;
5668                            yStart = yEnd = yEnd + style.shadow.width / 2;
5669                        } else if (Math.abs(this.component.grid.getYend() - yStart) < 2) {
5670                            style.shadow.width /= 2;
5671                            yStart = yEnd = yEnd - style.shadow.width / 2;
5672                        }
5673                    }
5674                    this._axisShadowShape.style = {
5675                        xStart: xStart,
5676                        yStart: yStart,
5677                        xEnd: xEnd,
5678                        yEnd: yEnd,
5679                        strokeColor: style.shadow.color,
5680                        lineWidth: style.shadow.width
5681                    };
5682                    this._axisShadowShape.invisible = false;
5683                    this.zr.modShape(this._axisShadowShape.id);
5684                }
5685                this.zr.refreshNextFrame();
5686            }
5687        },
5688        __onmousemove: function (param) {
5689            clearTimeout(this._hidingTicket);
5690            clearTimeout(this._showingTicket);
5691            if (this._mousein && this._enterable) {
5692                return;
5693            }
5694            var target = param.target;
5695            var mx = zrEvent.getX(param.event);
5696            var my = zrEvent.getY(param.event);
5697            if (!target) {
5698                this._curTarget = false;
5699                this._event = param.event;
5700                this._event.zrenderX = mx;
5701                this._event.zrenderY = my;
5702                if (this._needAxisTrigger && this.component.grid && zrArea.isInside(rectangleInstance, this.component.grid.getArea(), mx, my)) {
5703                    this._showingTicket = setTimeout(this._tryShow, this._showDelay);
5704                } else if (this._needAxisTrigger && this.component.polar && this.component.polar.isInside([
5705                        mx,
5706                        my
5707                    ]) != -1) {
5708                    this._showingTicket = setTimeout(this._tryShow, this._showDelay);
5709                } else {
5710                    !this._event.connectTrigger && this.messageCenter.dispatch(ecConfig.EVENT.TOOLTIP_OUT_GRID, this._event, null, this.myChart);
5711                    this._hidingTicket = setTimeout(this._hide, this._hideDelay);
5712                }
5713            } else {
5714                this._curTarget = target;
5715                this._event = param.event;
5716                this._event.zrenderX = mx;
5717                this._event.zrenderY = my;
5718                var polarIndex;
5719                if (this._needAxisTrigger && this.component.polar && (polarIndex = this.component.polar.isInside([
5720                        mx,
5721                        my
5722                    ])) != -1) {
5723                    var series = this.option.series;
5724                    for (var i = 0, l = series.length; i < l; i++) {
5725                        if (series[i].polarIndex === polarIndex && this.deepQuery([
5726                                series[i],
5727                                this.option
5728                            ], 'tooltip.trigger') === 'axis') {
5729                            this._curTarget = null;
5730                            break;
5731                        }
5732                    }
5733                }
5734                this._showingTicket = setTimeout(this._tryShow, this._showDelay);
5735            }
5736        },
5737        __onglobalout: function () {
5738            clearTimeout(this._hidingTicket);
5739            clearTimeout(this._showingTicket);
5740            this._hidingTicket = setTimeout(this._hide, this._hideDelay);
5741        },
5742        __setContent: function (ticket, content) {
5743            if (!this._tDom) {
5744                return;
5745            }
5746            if (ticket === this._curTicket) {
5747                this._tDom.innerHTML = content;
5748            }
5749            setTimeout(this._refixed, 20);
5750        },
5751        ontooltipHover: function (param, tipShape) {
5752            if (!this._lastTipShape || this._lastTipShape && this._lastTipShape.dataIndex != param.dataIndex) {
5753                if (this._lastTipShape && this._lastTipShape.tipShape.length > 0) {
5754                    this.zr.delShape(this._lastTipShape.tipShape);
5755                    this.shapeList.length = 2;
5756                }
5757                for (var i = 0, l = tipShape.length; i < l; i++) {
5758                    tipShape[i].zlevel = this.getZlevelBase();
5759                    tipShape[i].z = this.getZBase();
5760                    tipShape[i].style = zrShapeBase.prototype.getHighlightStyle(tipShape[i].style, tipShape[i].highlightStyle);
5761                    tipShape[i].draggable = false;
5762                    tipShape[i].hoverable = false;
5763                    tipShape[i].clickable = false;
5764                    tipShape[i].ondragend = null;
5765                    tipShape[i].ondragover = null;
5766                    tipShape[i].ondrop = null;
5767                    this.shapeList.push(tipShape[i]);
5768                    this.zr.addShape(tipShape[i]);
5769                }
5770                this._lastTipShape = {
5771                    dataIndex: param.dataIndex,
5772                    tipShape: tipShape
5773                };
5774            }
5775        },
5776        ondragend: function () {
5777            this._hide();
5778        },
5779        onlegendSelected: function (param) {
5780            this._selectedMap = param.selected;
5781        },
5782        _setSelectedMap: function () {
5783            if (this.component.legend) {
5784                this._selectedMap = zrUtil.clone(this.component.legend.getSelectedMap());
5785            } else {
5786                this._selectedMap = {};
5787            }
5788        },
5789        _isSelected: function (itemName) {
5790            if (this._selectedMap[itemName] != null) {
5791                return this._selectedMap[itemName];
5792            } else {
5793                return true;
5794            }
5795        },
5796        showTip: function (params) {
5797            if (!params) {
5798                return;
5799            }
5800            var seriesIndex;
5801            var series = this.option.series;
5802            if (params.seriesIndex != null) {
5803                seriesIndex = params.seriesIndex;
5804            } else {
5805                var seriesName = params.seriesName;
5806                for (var i = 0, l = series.length; i < l; i++) {
5807                    if (series[i].name === seriesName) {
5808                        seriesIndex = i;
5809                        break;
5810                    }
5811                }
5812            }
5813            var serie = series[seriesIndex];
5814            if (serie == null) {
5815                return;
5816            }
5817            var chart = this.myChart.chart[serie.type];
5818            var isAxisTrigger = this.deepQuery([
5819                serie,
5820                this.option
5821            ], 'tooltip.trigger') === 'axis';
5822            if (!chart) {
5823                return;
5824            }
5825            if (isAxisTrigger) {
5826                var dataIndex = params.dataIndex;
5827                switch (chart.type) {
5828                case ecConfig.CHART_TYPE_LINE:
5829                case ecConfig.CHART_TYPE_BAR:
5830                case ecConfig.CHART_TYPE_K:
5831                case ecConfig.CHART_TYPE_RADAR:
5832                    if (this.component.polar == null || serie.data[0].value.length <= dataIndex) {
5833                        return;
5834                    }
5835                    var polarIndex = serie.polarIndex || 0;
5836                    var vector = this.component.polar.getVector(polarIndex, dataIndex, 'max');
5837                    this._event = {
5838                        zrenderX: vector[0],
5839                        zrenderY: vector[1]
5840                    };
5841                    this._showPolarTrigger(polarIndex, dataIndex);
5842                    break;
5843                }
5844            } else {
5845                var shapeList = chart.shapeList;
5846                var x;
5847                var y;
5848                switch (chart.type) {
5849                case ecConfig.CHART_TYPE_LINE:
5850                case ecConfig.CHART_TYPE_BAR:
5851                case ecConfig.CHART_TYPE_K:
5852                case ecConfig.CHART_TYPE_TREEMAP:
5853                case ecConfig.CHART_TYPE_SCATTER:
5854                    var dataIndex = params.dataIndex;
5855                    for (var i = 0, l = shapeList.length; i < l; i++) {
5856                        if (shapeList[i]._mark == null && ecData.get(shapeList[i], 'seriesIndex') == seriesIndex && ecData.get(shapeList[i], 'dataIndex') == dataIndex) {
5857                            this._curTarget = shapeList[i];
5858                            x = shapeList[i].style.x;
5859                            y = chart.type != ecConfig.CHART_TYPE_K ? shapeList[i].style.y : shapeList[i].style.y[0];
5860                            break;
5861                        }
5862                    }
5863                    break;
5864                case ecConfig.CHART_TYPE_RADAR:
5865                    var dataIndex = params.dataIndex;
5866                    for (var i = 0, l = shapeList.length; i < l; i++) {
5867                        if (shapeList[i].type === 'polygon' && ecData.get(shapeList[i], 'seriesIndex') == seriesIndex && ecData.get(shapeList[i], 'dataIndex') == dataIndex) {
5868                            this._curTarget = shapeList[i];
5869                            var vector = this.component.polar.getCenter(serie.polarIndex || 0);
5870                            x = vector[0];
5871                            y = vector[1];
5872                            break;
5873                        }
5874                    }
5875                    break;
5876                case ecConfig.CHART_TYPE_PIE:
5877                    var name = params.name;
5878                    for (var i = 0, l = shapeList.length; i < l; i++) {
5879                        if (shapeList[i].type === 'sector' && ecData.get(shapeList[i], 'seriesIndex') == seriesIndex && ecData.get(shapeList[i], 'name') == name) {
5880                            this._curTarget = shapeList[i];
5881                            var style = this._curTarget.style;
5882                            var midAngle = (style.startAngle + style.endAngle) / 2 * Math.PI / 180;
5883                            x = this._curTarget.style.x + Math.cos(midAngle) * style.r / 1.5;
5884                            y = this._curTarget.style.y - Math.sin(midAngle) * style.r / 1.5;
5885                            break;
5886                        }
5887                    }
5888                    break;
5889                case ecConfig.CHART_TYPE_MAP:
5890                    var name = params.name;
5891                    var mapType = serie.mapType;
5892                    for (var i = 0, l = shapeList.length; i < l; i++) {
5893                        if (shapeList[i].type === 'text' && shapeList[i]._mapType === mapType && shapeList[i].style._name === name) {
5894                            this._curTarget = shapeList[i];
5895                            x = this._curTarget.style.x + this._curTarget.position[0];
5896                            y = this._curTarget.style.y + this._curTarget.position[1];
5897                            break;
5898                        }
5899                    }
5900                    break;
5901                case ecConfig.CHART_TYPE_CHORD:
5902                    var name = params.name;
5903                    for (var i = 0, l = shapeList.length; i < l; i++) {
5904                        if (shapeList[i].type === 'sector' && ecData.get(shapeList[i], 'name') == name) {
5905                            this._curTarget = shapeList[i];
5906                            var style = this._curTarget.style;
5907                            var midAngle = (style.startAngle + style.endAngle) / 2 * Math.PI / 180;
5908                            x = this._curTarget.style.x + Math.cos(midAngle) * (style.r - 2);
5909                            y = this._curTarget.style.y - Math.sin(midAngle) * (style.r - 2);
5910                            this.zr.trigger(zrConfig.EVENT.MOUSEMOVE, {
5911                                zrenderX: x,
5912                                zrenderY: y
5913                            });
5914                            return;
5915                        }
5916                    }
5917                    break;
5918                case ecConfig.CHART_TYPE_FORCE:
5919                    var name = params.name;
5920                    for (var i = 0, l = shapeList.length; i < l; i++) {
5921                        if (shapeList[i].type === 'circle' && ecData.get(shapeList[i], 'name') == name) {
5922                            this._curTarget = shapeList[i];
5923                            x = this._curTarget.position[0];
5924                            y = this._curTarget.position[1];
5925                            break;
5926                        }
5927                    }
5928                    break;
5929                }
5930                if (x != null && y != null) {
5931                    this._event = {
5932                        zrenderX: x,
5933                        zrenderY: y
5934                    };
5935                    this.zr.addHoverShape(this._curTarget);
5936                    this.zr.refreshHover();
5937                    this._showItemTrigger();
5938                }
5939            }
5940        },
5941        hideTip: function () {
5942            this._hide();
5943        },
5944        refresh: function (newOption) {
5945            this._zrHeight = this.zr.getHeight();
5946            this._zrWidth = this.zr.getWidth();
5947            if (this._lastTipShape && this._lastTipShape.tipShape.length > 0) {
5948                this.zr.delShape(this._lastTipShape.tipShape);
5949            }
5950            this._lastTipShape = false;
5951            this.shapeList.length = 2;
5952            this._lastDataIndex = -1;
5953            this._lastSeriesIndex = -1;
5954            this._lastItemTriggerId = -1;
5955            if (newOption) {
5956                this.option = newOption;
5957                this.option.tooltip = this.reformOption(this.option.tooltip);
5958                this.option.tooltip.textStyle = zrUtil.merge(this.option.tooltip.textStyle, this.ecTheme.textStyle);
5959                this._needAxisTrigger = false;
5960                if (this.option.tooltip.trigger === 'axis') {
5961                    this._needAxisTrigger = true;
5962                }
5963                var series = this.option.series;
5964                for (var i = 0, l = series.length; i < l; i++) {
5965                    if (this.query(series[i], 'tooltip.trigger') === 'axis') {
5966                        this._needAxisTrigger = true;
5967                        break;
5968                    }
5969                }
5970                this._showDelay = this.option.tooltip.showDelay;
5971                this._hideDelay = this.option.tooltip.hideDelay;
5972                this._defaultCssText = this._style(this.option.tooltip);
5973                this._setSelectedMap();
5974                this._axisLineWidth = this.option.tooltip.axisPointer.lineStyle.width;
5975                this._enterable = this.option.tooltip.enterable;
5976                if (!this._enterable && this._tDom.className.indexOf(zrConfig.elementClassName) < 0) {
5977                    this._tDom.className += ' ' + zrConfig.elementClassName;
5978                }
5979            }
5980            if (this.showing) {
5981                var self = this;
5982                setTimeout(function () {
5983                    self.zr.trigger(zrConfig.EVENT.MOUSEMOVE, self.zr.handler._event);
5984                }, 50);
5985            }
5986        },
5987        onbeforDispose: function () {
5988            if (this._lastTipShape && this._lastTipShape.tipShape.length > 0) {
5989                this.zr.delShape(this._lastTipShape.tipShape);
5990            }
5991            clearTimeout(this._hidingTicket);
5992            clearTimeout(this._showingTicket);
5993            this.zr.un(zrConfig.EVENT.MOUSEMOVE, this._onmousemove);
5994            this.zr.un(zrConfig.EVENT.GLOBALOUT, this._onglobalout);
5995            if (this.hasAppend && !!this.dom.firstChild) {
5996                this.dom.firstChild.removeChild(this._tDom);
5997            }
5998            this._tDom = null;
5999        },
6000        _encodeHTML: function (source) {
6001            return String(source).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
6002        }
6003    };
6004    zrUtil.inherits(Tooltip, Base);
6005    require('../component').define('tooltip', Tooltip);
6006    return Tooltip;
6007});define('echarts/component/legend', [
6008    'require',
6009    './base',
6010    'zrender/shape/Text',
6011    'zrender/shape/Rectangle',
6012    'zrender/shape/Sector',
6013    '../util/shape/Icon',
6014    '../util/shape/Candle',
6015    '../config',
6016    'zrender/tool/util',
6017    'zrender/tool/area',
6018    '../component'
6019], function (require) {
6020    var Base = require('./base');
6021    var TextShape = require('zrender/shape/Text');
6022    var RectangleShape = require('zrender/shape/Rectangle');
6023    var SectorShape = require('zrender/shape/Sector');
6024    var IconShape = require('../util/shape/Icon');
6025    var CandleShape = require('../util/shape/Candle');
6026    var ecConfig = require('../config');
6027    ecConfig.legend = {
6028        zlevel: 0,
6029        z: 4,
6030        show: true,
6031        orient: 'horizontal',
6032        x: 'center',
6033        y: 'top',
6034        backgroundColor: 'rgba(0,0,0,0)',
6035        borderColor: '#ccc',
6036        borderWidth: 0,
6037        padding: 5,
6038        itemGap: 10,
6039        itemWidth: 20,
6040        itemHeight: 14,
6041        textStyle: { color: '#333' },
6042        selectedMode: true
6043    };
6044    var zrUtil = require('zrender/tool/util');
6045    var zrArea = require('zrender/tool/area');
6046    function Legend(ecTheme, messageCenter, zr, option, myChart) {
6047        if (!this.query(option, 'legend.data')) {
6048            console.error('option.legend.data has not been defined.');
6049            return;
6050        }
6051        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
6052        var self = this;
6053        self._legendSelected = function (param) {
6054            self.__legendSelected(param);
6055        };
6056        self._dispatchHoverLink = function (param) {
6057            return self.__dispatchHoverLink(param);
6058        };
6059        this._colorIndex = 0;
6060        this._colorMap = {};
6061        this._selectedMap = {};
6062        this._hasDataMap = {};
6063        this.refresh(option);
6064    }
6065    Legend.prototype = {
6066        type: ecConfig.COMPONENT_TYPE_LEGEND,
6067        _buildShape: function () {
6068            if (!this.legendOption.show) {
6069                return;
6070            }
6071            this._itemGroupLocation = this._getItemGroupLocation();
6072            this._buildBackground();
6073            this._buildItem();
6074            for (var i = 0, l = this.shapeList.length; i < l; i++) {
6075                this.zr.addShape(this.shapeList[i]);
6076            }
6077        },
6078        _buildItem: function () {
6079            var data = this.legendOption.data;
6080            var dataLength = data.length;
6081            var itemName;
6082            var itemType;
6083            var itemShape;
6084            var textShape;
6085            var textStyle = this.legendOption.textStyle;
6086            var dataTextStyle;
6087            var dataFont;
6088            var formattedName;
6089            var zrWidth = this.zr.getWidth();
6090            var zrHeight = this.zr.getHeight();
6091            var lastX = this._itemGroupLocation.x;
6092            var lastY = this._itemGroupLocation.y;
6093            var itemWidth = this.legendOption.itemWidth;
6094            var itemHeight = this.legendOption.itemHeight;
6095            var itemGap = this.legendOption.itemGap;
6096            var color;
6097            if (this.legendOption.orient === 'vertical' && this.legendOption.x === 'right') {
6098                lastX = this._itemGroupLocation.x + this._itemGroupLocation.width - itemWidth;
6099            }
6100            for (var i = 0; i < dataLength; i++) {
6101                dataTextStyle = zrUtil.merge(data[i].textStyle || {}, textStyle);
6102                dataFont = this.getFont(dataTextStyle);
6103                itemName = this._getName(data[i]);
6104                formattedName = this._getFormatterName(itemName);
6105                if (itemName === '') {
6106                    if (this.legendOption.orient === 'horizontal') {
6107                        lastX = this._itemGroupLocation.x;
6108                        lastY += itemHeight + itemGap;
6109                    } else {
6110                        this.legendOption.x === 'right' ? lastX -= this._itemGroupLocation.maxWidth + itemGap : lastX += this._itemGroupLocation.maxWidth + itemGap;
6111                        lastY = this._itemGroupLocation.y;
6112                    }
6113                    continue;
6114                }
6115                itemType = data[i].icon || this._getSomethingByName(itemName).type;
6116                color = this.getColor(itemName);
6117                if (this.legendOption.orient === 'horizontal') {
6118                    if (zrWidth - lastX < 200 && itemWidth + 5 + zrArea.getTextWidth(formattedName, dataFont) + (i === dataLength - 1 || data[i + 1] === '' ? 0 : itemGap) >= zrWidth - lastX) {
6119                        lastX = this._itemGroupLocation.x;
6120                        lastY += itemHeight + itemGap;
6121                    }
6122                } else {
6123                    if (zrHeight - lastY < 200 && itemHeight + (i === dataLength - 1 || data[i + 1] === '' ? 0 : itemGap) >= zrHeight - lastY) {
6124                        this.legendOption.x === 'right' ? lastX -= this._itemGroupLocation.maxWidth + itemGap : lastX += this._itemGroupLocation.maxWidth + itemGap;
6125                        lastY = this._itemGroupLocation.y;
6126                    }
6127                }
6128                itemShape = this._getItemShapeByType(lastX, lastY, itemWidth, itemHeight, this._selectedMap[itemName] && this._hasDataMap[itemName] ? color : '#ccc', itemType, color);
6129                itemShape._name = itemName;
6130                itemShape = new IconShape(itemShape);
6131                textShape = {
6132                    zlevel: this.getZlevelBase(),
6133                    z: this.getZBase(),
6134                    style: {
6135                        x: lastX + itemWidth + 5,
6136                        y: lastY + itemHeight / 2,
6137                        color: this._selectedMap[itemName] ? dataTextStyle.color === 'auto' ? color : dataTextStyle.color : '#ccc',
6138                        text: formattedName,
6139                        textFont: dataFont,
6140                        textBaseline: 'middle'
6141                    },
6142                    highlightStyle: {
6143                        color: color,
6144                        brushType: 'fill'
6145                    },
6146                    hoverable: !!this.legendOption.selectedMode,
6147                    clickable: !!this.legendOption.selectedMode
6148                };
6149                if (this.legendOption.orient === 'vertical' && this.legendOption.x === 'right') {
6150                    textShape.style.x -= itemWidth + 10;
6151                    textShape.style.textAlign = 'right';
6152                }
6153                textShape._name = itemName;
6154                textShape = new TextShape(textShape);
6155                if (this.legendOption.selectedMode) {
6156                    itemShape.onclick = textShape.onclick = this._legendSelected;
6157                    itemShape.onmouseover = textShape.onmouseover = this._dispatchHoverLink;
6158                    itemShape.hoverConnect = textShape.id;
6159                    textShape.hoverConnect = itemShape.id;
6160                }
6161                this.shapeList.push(itemShape);
6162                this.shapeList.push(textShape);
6163                if (this.legendOption.orient === 'horizontal') {
6164                    lastX += itemWidth + 5 + zrArea.getTextWidth(formattedName, dataFont) + itemGap;
6165                } else {
6166                    lastY += itemHeight + itemGap;
6167                }
6168            }
6169            if (this.legendOption.orient === 'horizontal' && this.legendOption.x === 'center' && lastY != this._itemGroupLocation.y) {
6170                this._mLineOptimize();
6171            }
6172        },
6173        _getName: function (data) {
6174            return typeof data.name != 'undefined' ? data.name : data;
6175        },
6176        _getFormatterName: function (itemName) {
6177            var formatter = this.legendOption.formatter;
6178            var formattedName;
6179            if (typeof formatter === 'function') {
6180                formattedName = formatter.call(this.myChart, itemName);
6181            } else if (typeof formatter === 'string') {
6182                formattedName = formatter.replace('{name}', itemName);
6183            } else {
6184                formattedName = itemName;
6185            }
6186            return formattedName;
6187        },
6188        _getFormatterNameFromData: function (data) {
6189            var itemName = this._getName(data);
6190            return this._getFormatterName(itemName);
6191        },
6192        _mLineOptimize: function () {
6193            var lineOffsetArray = [];
6194            var lastX = this._itemGroupLocation.x;
6195            for (var i = 2, l = this.shapeList.length; i < l; i++) {
6196                if (this.shapeList[i].style.x === lastX) {
6197                    lineOffsetArray.push((this._itemGroupLocation.width - (this.shapeList[i - 1].style.x + zrArea.getTextWidth(this.shapeList[i - 1].style.text, this.shapeList[i - 1].style.textFont) - lastX)) / 2);
6198                } else if (i === l - 1) {
6199                    lineOffsetArray.push((this._itemGroupLocation.width - (this.shapeList[i].style.x + zrArea.getTextWidth(this.shapeList[i].style.text, this.shapeList[i].style.textFont) - lastX)) / 2);
6200                }
6201            }
6202            var curLineIndex = -1;
6203            for (var i = 1, l = this.shapeList.length; i < l; i++) {
6204                if (this.shapeList[i].style.x === lastX) {
6205                    curLineIndex++;
6206                }
6207                if (lineOffsetArray[curLineIndex] === 0) {
6208                    continue;
6209                } else {
6210                    this.shapeList[i].style.x += lineOffsetArray[curLineIndex];
6211                }
6212            }
6213        },
6214        _buildBackground: function () {
6215            var padding = this.reformCssArray(this.legendOption.padding);
6216            this.shapeList.push(new RectangleShape({
6217                zlevel: this.getZlevelBase(),
6218                z: this.getZBase(),
6219                hoverable: false,
6220                style: {
6221                    x: this._itemGroupLocation.x - padding[3],
6222                    y: this._itemGroupLocation.y - padding[0],
6223                    width: this._itemGroupLocation.width + padding[3] + padding[1],
6224                    height: this._itemGroupLocation.height + padding[0] + padding[2],
6225                    brushType: this.legendOption.borderWidth === 0 ? 'fill' : 'both',
6226                    color: this.legendOption.backgroundColor,
6227                    strokeColor: this.legendOption.borderColor,
6228                    lineWidth: this.legendOption.borderWidth
6229                }
6230            }));
6231        },
6232        _getItemGroupLocation: function () {
6233            var data = this.legendOption.data;
6234            var dataLength = data.length;
6235            var itemGap = this.legendOption.itemGap;
6236            var itemWidth = this.legendOption.itemWidth + 5;
6237            var itemHeight = this.legendOption.itemHeight;
6238            var textStyle = this.legendOption.textStyle;
6239            var font = this.getFont(textStyle);
6240            var totalWidth = 0;
6241            var totalHeight = 0;
6242            var padding = this.reformCssArray(this.legendOption.padding);
6243            var zrWidth = this.zr.getWidth() - padding[1] - padding[3];
6244            var zrHeight = this.zr.getHeight() - padding[0] - padding[2];
6245            var temp = 0;
6246            var maxWidth = 0;
6247            if (this.legendOption.orient === 'horizontal') {
6248                totalHeight = itemHeight;
6249                for (var i = 0; i < dataLength; i++) {
6250                    if (this._getName(data[i]) === '') {
6251                        temp -= itemGap;
6252                        totalWidth = Math.max(totalWidth, temp);
6253                        totalHeight += itemHeight + itemGap;
6254                        temp = 0;
6255                        continue;
6256                    }
6257                    var tempTextWidth = zrArea.getTextWidth(this._getFormatterNameFromData(data[i]), data[i].textStyle ? this.getFont(zrUtil.merge(data[i].textStyle || {}, textStyle)) : font);
6258                    if (temp + itemWidth + tempTextWidth + itemGap > zrWidth) {
6259                        temp -= itemGap;
6260                        totalWidth = Math.max(totalWidth, temp);
6261                        totalHeight += itemHeight + itemGap;
6262                        temp = 0;
6263                    } else {
6264                        temp += itemWidth + tempTextWidth + itemGap;
6265                        totalWidth = Math.max(totalWidth, temp - itemGap);
6266                    }
6267                }
6268            } else {
6269                for (var i = 0; i < dataLength; i++) {
6270                    maxWidth = Math.max(maxWidth, zrArea.getTextWidth(this._getFormatterNameFromData(data[i]), data[i].textStyle ? this.getFont(zrUtil.merge(data[i].textStyle || {}, textStyle)) : font));
6271                }
6272                maxWidth += itemWidth;
6273                totalWidth = maxWidth;
6274                for (var i = 0; i < dataLength; i++) {
6275                    if (this._getName(data[i]) === '') {
6276                        totalWidth += maxWidth + itemGap;
6277                        temp -= itemGap;
6278                        totalHeight = Math.max(totalHeight, temp);
6279                        temp = 0;
6280                        continue;
6281                    }
6282                    if (temp + itemHeight + itemGap > zrHeight) {
6283                        totalWidth += maxWidth + itemGap;
6284                        temp -= itemGap;
6285                        totalHeight = Math.max(totalHeight, temp);
6286                        temp = 0;
6287                    } else {
6288                        temp += itemHeight + itemGap;
6289                        totalHeight = Math.max(totalHeight, temp - itemGap);
6290                    }
6291                }
6292            }
6293            zrWidth = this.zr.getWidth();
6294            zrHeight = this.zr.getHeight();
6295            var x;
6296            switch (this.legendOption.x) {
6297            case 'center':
6298                x = Math.floor((zrWidth - totalWidth) / 2);
6299                break;
6300            case 'left':
6301                x = padding[3] + this.legendOption.borderWidth;
6302                break;
6303            case 'right':
6304                x = zrWidth - totalWidth - padding[1] - padding[3] - this.legendOption.borderWidth * 2;
6305                break;
6306            default:
6307                x = this.parsePercent(this.legendOption.x, zrWidth);
6308                break;
6309            }
6310            var y;
6311            switch (this.legendOption.y) {
6312            case 'top':
6313                y = padding[0] + this.legendOption.borderWidth;
6314                break;
6315            case 'bottom':
6316                y = zrHeight - totalHeight - padding[0] - padding[2] - this.legendOption.borderWidth * 2;
6317                break;
6318            case 'center':
6319                y = Math.floor((zrHeight - totalHeight) / 2);
6320                break;
6321            default:
6322                y = this.parsePercent(this.legendOption.y, zrHeight);
6323                break;
6324            }
6325            return {
6326                x: x,
6327                y: y,
6328                width: totalWidth,
6329                height: totalHeight,
6330                maxWidth: maxWidth
6331            };
6332        },
6333        _getSomethingByName: function (name) {
6334            var series = this.option.series;
6335            var data;
6336            for (var i = 0, l = series.length; i < l; i++) {
6337                if (series[i].name === name) {
6338                    return {
6339                        type: series[i].type,
6340                        series: series[i],
6341                        seriesIndex: i,
6342                        data: null,
6343                        dataIndex: -1
6344                    };
6345                }
6346                if (series[i].type === ecConfig.CHART_TYPE_PIE || series[i].type === ecConfig.CHART_TYPE_RADAR || series[i].type === ecConfig.CHART_TYPE_CHORD || series[i].type === ecConfig.CHART_TYPE_FORCE || series[i].type === ecConfig.CHART_TYPE_FUNNEL || series[i].type === ecConfig.CHART_TYPE_TREEMAP) {
6347                    data = series[i].categories || series[i].data || series[i].nodes;
6348                    for (var j = 0, k = data.length; j < k; j++) {
6349                        if (data[j].name === name) {
6350                            return {
6351                                type: series[i].type,
6352                                series: series[i],
6353                                seriesIndex: i,
6354                                data: data[j],
6355                                dataIndex: j
6356                            };
6357                        }
6358                    }
6359                }
6360            }
6361            return {
6362                type: 'bar',
6363                series: null,
6364                seriesIndex: -1,
6365                data: null,
6366                dataIndex: -1
6367            };
6368        },
6369        _getItemShapeByType: function (x, y, width, height, color, itemType, defaultColor) {
6370            var highlightColor = color === '#ccc' ? defaultColor : color;
6371            var itemShape = {
6372                zlevel: this.getZlevelBase(),
6373                z: this.getZBase(),
6374                style: {
6375                    iconType: 'legendicon' + itemType,
6376                    x: x,
6377                    y: y,
6378                    width: width,
6379                    height: height,
6380                    color: color,
6381                    strokeColor: color,
6382                    lineWidth: 2
6383                },
6384                highlightStyle: {
6385                    color: highlightColor,
6386                    strokeColor: highlightColor,
6387                    lineWidth: 1
6388                },
6389                hoverable: this.legendOption.selectedMode,
6390                clickable: this.legendOption.selectedMode
6391            };
6392            var imageLocation;
6393            if (itemType.match('image')) {
6394                var imageLocation = itemType.replace(new RegExp('^image:\\/\\/'), '');
6395                itemType = 'image';
6396            }
6397            switch (itemType) {
6398            case 'line':
6399                itemShape.style.brushType = 'stroke';
6400                itemShape.highlightStyle.lineWidth = 3;
6401                break;
6402            case 'radar':
6403            case 'venn':
6404            case 'tree':
6405            case 'treemap':
6406            case 'scatter':
6407                itemShape.highlightStyle.lineWidth = 3;
6408                break;
6409            case 'k':
6410                itemShape.style.brushType = 'both';
6411                itemShape.highlightStyle.lineWidth = 3;
6412                itemShape.highlightStyle.color = itemShape.style.color = this.deepQuery([
6413                    this.ecTheme,
6414                    ecConfig
6415                ], 'k.itemStyle.normal.color') || '#fff';
6416                itemShape.style.strokeColor = color != '#ccc' ? this.deepQuery([
6417                    this.ecTheme,
6418                    ecConfig
6419                ], 'k.itemStyle.normal.lineStyle.color') || '#ff3200' : color;
6420                break;
6421            case 'image':
6422                itemShape.style.iconType = 'image';
6423                itemShape.style.image = imageLocation;
6424                if (color === '#ccc') {
6425                    itemShape.style.opacity = 0.5;
6426                }
6427                break;
6428            }
6429            return itemShape;
6430        },
6431        __legendSelected: function (param) {
6432            var itemName = param.target._name;
6433            if (this.legendOption.selectedMode === 'single') {
6434                for (var k in this._selectedMap) {
6435                    this._selectedMap[k] = false;
6436                }
6437            }
6438            this._selectedMap[itemName] = !this._selectedMap[itemName];
6439            this.messageCenter.dispatch(ecConfig.EVENT.LEGEND_SELECTED, param.event, {
6440                selected: this._selectedMap,
6441                target: itemName
6442            }, this.myChart);
6443        },
6444        __dispatchHoverLink: function (param) {
6445            this.messageCenter.dispatch(ecConfig.EVENT.LEGEND_HOVERLINK, param.event, { target: param.target._name }, this.myChart);
6446            return;
6447        },
6448        refresh: function (newOption) {
6449            if (newOption) {
6450                this.option = newOption || this.option;
6451                this.option.legend = this.reformOption(this.option.legend);
6452                this.legendOption = this.option.legend;
6453                var data = this.legendOption.data || [];
6454                var itemName;
6455                var something;
6456                var color;
6457                var queryTarget;
6458                if (this.legendOption.selected) {
6459                    for (var k in this.legendOption.selected) {
6460                        this._selectedMap[k] = typeof this._selectedMap[k] != 'undefined' ? this._selectedMap[k] : this.legendOption.selected[k];
6461                    }
6462                }
6463                for (var i = 0, dataLength = data.length; i < dataLength; i++) {
6464                    itemName = this._getName(data[i]);
6465                    if (itemName === '') {
6466                        continue;
6467                    }
6468                    something = this._getSomethingByName(itemName);
6469                    if (!something.series) {
6470                        this._hasDataMap[itemName] = false;
6471                    } else {
6472                        this._hasDataMap[itemName] = true;
6473                        if (something.data && (something.type === ecConfig.CHART_TYPE_PIE || something.type === ecConfig.CHART_TYPE_FORCE || something.type === ecConfig.CHART_TYPE_FUNNEL)) {
6474                            queryTarget = [
6475                                something.data,
6476                                something.series
6477                            ];
6478                        } else {
6479                            queryTarget = [something.series];
6480                        }
6481                        color = this.getItemStyleColor(this.deepQuery(queryTarget, 'itemStyle.normal.color'), something.seriesIndex, something.dataIndex, something.data);
6482                        if (color && something.type != ecConfig.CHART_TYPE_K) {
6483                            this.setColor(itemName, color);
6484                        }
6485                        this._selectedMap[itemName] = this._selectedMap[itemName] != null ? this._selectedMap[itemName] : true;
6486                    }
6487                }
6488            }
6489            this.clear();
6490            this._buildShape();
6491        },
6492        getRelatedAmount: function (name) {
6493            var amount = 0;
6494            var series = this.option.series;
6495            var data;
6496            for (var i = 0, l = series.length; i < l; i++) {
6497                if (series[i].name === name) {
6498                    amount++;
6499                }
6500                if (series[i].type === ecConfig.CHART_TYPE_PIE || series[i].type === ecConfig.CHART_TYPE_RADAR || series[i].type === ecConfig.CHART_TYPE_CHORD || series[i].type === ecConfig.CHART_TYPE_FORCE || series[i].type === ecConfig.CHART_TYPE_FUNNEL) {
6501                    data = series[i].type != ecConfig.CHART_TYPE_FORCE ? series[i].data : series[i].categories;
6502                    for (var j = 0, k = data.length; j < k; j++) {
6503                        if (data[j].name === name && data[j].value != '-') {
6504                            amount++;
6505                        }
6506                    }
6507                }
6508            }
6509            return amount;
6510        },
6511        setColor: function (legendName, color) {
6512            this._colorMap[legendName] = color;
6513        },
6514        getColor: function (legendName) {
6515            if (!this._colorMap[legendName]) {
6516                this._colorMap[legendName] = this.zr.getColor(this._colorIndex++);
6517            }
6518            return this._colorMap[legendName];
6519        },
6520        hasColor: function (legendName) {
6521            return this._colorMap[legendName] ? this._colorMap[legendName] : false;
6522        },
6523        add: function (name, color) {
6524            var data = this.legendOption.data;
6525            for (var i = 0, dataLength = data.length; i < dataLength; i++) {
6526                if (this._getName(data[i]) === name) {
6527                    return;
6528                }
6529            }
6530            this.legendOption.data.push(name);
6531            this.setColor(name, color);
6532            this._selectedMap[name] = true;
6533            this._hasDataMap[name] = true;
6534        },
6535        del: function (name) {
6536            var data = this.legendOption.data;
6537            for (var i = 0, dataLength = data.length; i < dataLength; i++) {
6538                if (this._getName(data[i]) === name) {
6539                    return this.legendOption.data.splice(i, 1);
6540                }
6541            }
6542        },
6543        getItemShape: function (name) {
6544            if (name == null) {
6545                return;
6546            }
6547            var shape;
6548            for (var i = 0, l = this.shapeList.length; i < l; i++) {
6549                shape = this.shapeList[i];
6550                if (shape._name === name && shape.type != 'text') {
6551                    return shape;
6552                }
6553            }
6554        },
6555        setItemShape: function (name, itemShape) {
6556            var shape;
6557            for (var i = 0, l = this.shapeList.length; i < l; i++) {
6558                shape = this.shapeList[i];
6559                if (shape._name === name && shape.type != 'text') {
6560                    if (!this._selectedMap[name]) {
6561                        itemShape.style.color = '#ccc';
6562                        itemShape.style.strokeColor = '#ccc';
6563                    }
6564                    this.zr.modShape(shape.id, itemShape);
6565                }
6566            }
6567        },
6568        isSelected: function (itemName) {
6569            if (typeof this._selectedMap[itemName] != 'undefined') {
6570                return this._selectedMap[itemName];
6571            } else {
6572                return true;
6573            }
6574        },
6575        getSelectedMap: function () {
6576            return this._selectedMap;
6577        },
6578        setSelected: function (itemName, selectStatus) {
6579            if (this.legendOption.selectedMode === 'single') {
6580                for (var k in this._selectedMap) {
6581                    this._selectedMap[k] = false;
6582                }
6583            }
6584            this._selectedMap[itemName] = selectStatus;
6585            this.messageCenter.dispatch(ecConfig.EVENT.LEGEND_SELECTED, null, {
6586                selected: this._selectedMap,
6587                target: itemName
6588            }, this.myChart);
6589        },
6590        onlegendSelected: function (param, status) {
6591            var legendSelected = param.selected;
6592            for (var itemName in legendSelected) {
6593                if (this._selectedMap[itemName] != legendSelected[itemName]) {
6594                    status.needRefresh = true;
6595                }
6596                this._selectedMap[itemName] = legendSelected[itemName];
6597            }
6598            return;
6599        }
6600    };
6601    var legendIcon = {
6602        line: function (ctx, style) {
6603            var dy = style.height / 2;
6604            ctx.moveTo(style.x, style.y + dy);
6605            ctx.lineTo(style.x + style.width, style.y + dy);
6606        },
6607        pie: function (ctx, style) {
6608            var x = style.x;
6609            var y = style.y;
6610            var width = style.width;
6611            var height = style.height;
6612            SectorShape.prototype.buildPath(ctx, {
6613                x: x + width / 2,
6614                y: y + height + 2,
6615                r: height,
6616                r0: 6,
6617                startAngle: 45,
6618                endAngle: 135
6619            });
6620        },
6621        eventRiver: function (ctx, style) {
6622            var x = style.x;
6623            var y = style.y;
6624            var width = style.width;
6625            var height = style.height;
6626            ctx.moveTo(x, y + height);
6627            ctx.bezierCurveTo(x + width, y + height, x, y + 4, x + width, y + 4);
6628            ctx.lineTo(x + width, y);
6629            ctx.bezierCurveTo(x, y, x + width, y + height - 4, x, y + height - 4);
6630            ctx.lineTo(x, y + height);
6631        },
6632        k: function (ctx, style) {
6633            var x = style.x;
6634            var y = style.y;
6635            var width = style.width;
6636            var height = style.height;
6637            CandleShape.prototype.buildPath(ctx, {
6638                x: x + width / 2,
6639                y: [
6640                    y + 1,
6641                    y + 1,
6642                    y + height - 6,
6643                    y + height
6644                ],
6645                width: width - 6
6646            });
6647        },
6648        bar: function (ctx, style) {
6649            var x = style.x;
6650            var y = style.y + 1;
6651            var width = style.width;
6652            var height = style.height - 2;
6653            var r = 3;
6654            ctx.moveTo(x + r, y);
6655            ctx.lineTo(x + width - r, y);
6656            ctx.quadraticCurveTo(x + width, y, x + width, y + r);
6657            ctx.lineTo(x + width, y + height - r);
6658            ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
6659            ctx.lineTo(x + r, y + height);
6660            ctx.quadraticCurveTo(x, y + height, x, y + height - r);
6661            ctx.lineTo(x, y + r);
6662            ctx.quadraticCurveTo(x, y, x + r, y);
6663        },
6664        force: function (ctx, style) {
6665            IconShape.prototype.iconLibrary.circle(ctx, style);
6666        },
6667        radar: function (ctx, style) {
6668            var n = 6;
6669            var x = style.x + style.width / 2;
6670            var y = style.y + style.height / 2;
6671            var r = style.height / 2;
6672            var dStep = 2 * Math.PI / n;
6673            var deg = -Math.PI / 2;
6674            var xStart = x + r * Math.cos(deg);
6675            var yStart = y + r * Math.sin(deg);
6676            ctx.moveTo(xStart, yStart);
6677            deg += dStep;
6678            for (var i = 0, end = n - 1; i < end; i++) {
6679                ctx.lineTo(x + r * Math.cos(deg), y + r * Math.sin(deg));
6680                deg += dStep;
6681            }
6682            ctx.lineTo(xStart, yStart);
6683        }
6684    };
6685    legendIcon.chord = legendIcon.pie;
6686    legendIcon.map = legendIcon.bar;
6687    for (var k in legendIcon) {
6688        IconShape.prototype.iconLibrary['legendicon' + k] = legendIcon[k];
6689    }
6690    zrUtil.inherits(Legend, Base);
6691    require('../component').define('legend', Legend);
6692    return Legend;
6693});define('echarts/util/ecData', [], function () {
6694    function pack(shape, series, seriesIndex, data, dataIndex, name, special, special2) {
6695        var value;
6696        if (typeof data != 'undefined') {
6697            value = data.value == null ? data : data.value;
6698        }
6699        shape._echartsData = {
6700            '_series': series,
6701            '_seriesIndex': seriesIndex,
6702            '_data': data,
6703            '_dataIndex': dataIndex,
6704            '_name': name,
6705            '_value': value,
6706            '_special': special,
6707            '_special2': special2
6708        };
6709        return shape._echartsData;
6710    }
6711    function get(shape, key) {
6712        var data = shape._echartsData;
6713        if (!key) {
6714            return data;
6715        }
6716        switch (key) {
6717        case 'series':
6718        case 'seriesIndex':
6719        case 'data':
6720        case 'dataIndex':
6721        case 'name':
6722        case 'value':
6723        case 'special':
6724        case 'special2':
6725            return data && data['_' + key];
6726        }
6727        return null;
6728    }
6729    function set(shape, key, value) {
6730        shape._echartsData = shape._echartsData || {};
6731        switch (key) {
6732        case 'series':
6733        case 'seriesIndex':
6734        case 'data':
6735        case 'dataIndex':
6736        case 'name':
6737        case 'value':
6738        case 'special':
6739        case 'special2':
6740            shape._echartsData['_' + key] = value;
6741            break;
6742        }
6743    }
6744    function clone(source, target) {
6745        target._echartsData = {
6746            '_series': source._echartsData._series,
6747            '_seriesIndex': source._echartsData._seriesIndex,
6748            '_data': source._echartsData._data,
6749            '_dataIndex': source._echartsData._dataIndex,
6750            '_name': source._echartsData._name,
6751            '_value': source._echartsData._value,
6752            '_special': source._echartsData._special,
6753            '_special2': source._echartsData._special2
6754        };
6755    }
6756    return {
6757        pack: pack,
6758        set: set,
6759        get: get,
6760        clone: clone
6761    };
6762});define('echarts/chart', [], function () {
6763    var self = {};
6764    var _chartLibrary = {};
6765    self.define = function (name, clazz) {
6766        _chartLibrary[name] = clazz;
6767        return self;
6768    };
6769    self.get = function (name) {
6770        return _chartLibrary[name];
6771    };
6772    return self;
6773});define('zrender/tool/color', [
6774    'require',
6775    '../tool/util'
6776], function (require) {
6777    var util = require('../tool/util');
6778    var _ctx;
6779    var palette = [
6780        '#ff9277',
6781        ' #dddd00',
6782        ' #ffc877',
6783        ' #bbe3ff',
6784        ' #d5ffbb',
6785        '#bbbbff',
6786        ' #ddb000',
6787        ' #b0dd00',
6788        ' #e2bbff',
6789        ' #ffbbe3',
6790        '#ff7777',
6791        ' #ff9900',
6792        ' #83dd00',
6793        ' #77e3ff',
6794        ' #778fff',
6795        '#c877ff',
6796        ' #ff77ab',
6797        ' #ff6600',
6798        ' #aa8800',
6799        ' #77c7ff',
6800        '#ad77ff',
6801        ' #ff77ff',
6802        ' #dd0083',
6803        ' #777700',
6804        ' #00aa00',
6805        '#0088aa',
6806        ' #8400dd',
6807        ' #aa0088',
6808        ' #dd0000',
6809        ' #772e00'
6810    ];
6811    var _palette = palette;
6812    var highlightColor = 'rgba(255,255,0,0.5)';
6813    var _highlightColor = highlightColor;
6814    var colorRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i;
6815    var _nameColors = {
6816        aliceblue: '#f0f8ff',
6817        antiquewhite: '#faebd7',
6818        aqua: '#0ff',
6819        aquamarine: '#7fffd4',
6820        azure: '#f0ffff',
6821        beige: '#f5f5dc',
6822        bisque: '#ffe4c4',
6823        black: '#000',
6824        blanchedalmond: '#ffebcd',
6825        blue: '#00f',
6826        blueviolet: '#8a2be2',
6827        brown: '#a52a2a',
6828        burlywood: '#deb887',
6829        cadetblue: '#5f9ea0',
6830        chartreuse: '#7fff00',
6831        chocolate: '#d2691e',
6832        coral: '#ff7f50',
6833        cornflowerblue: '#6495ed',
6834        cornsilk: '#fff8dc',
6835        crimson: '#dc143c',
6836        cyan: '#0ff',
6837        darkblue: '#00008b',
6838        darkcyan: '#008b8b',
6839        darkgoldenrod: '#b8860b',
6840        darkgray: '#a9a9a9',
6841        darkgrey: '#a9a9a9',
6842        darkgreen: '#006400',
6843        darkkhaki: '#bdb76b',
6844        darkmagenta: '#8b008b',
6845        darkolivegreen: '#556b2f',
6846        darkorange: '#ff8c00',
6847        darkorchid: '#9932cc',
6848        darkred: '#8b0000',
6849        darksalmon: '#e9967a',
6850        darkseagreen: '#8fbc8f',
6851        darkslateblue: '#483d8b',
6852        darkslategray: '#2f4f4f',
6853        darkslategrey: '#2f4f4f',
6854        darkturquoise: '#00ced1',
6855        darkviolet: '#9400d3',
6856        deeppink: '#ff1493',
6857        deepskyblue: '#00bfff',
6858        dimgray: '#696969',
6859        dimgrey: '#696969',
6860        dodgerblue: '#1e90ff',
6861        firebrick: '#b22222',
6862        floralwhite: '#fffaf0',
6863        forestgreen: '#228b22',
6864        fuchsia: '#f0f',
6865        gainsboro: '#dcdcdc',
6866        ghostwhite: '#f8f8ff',
6867        gold: '#ffd700',
6868        goldenrod: '#daa520',
6869        gray: '#808080',
6870        grey: '#808080',
6871        green: '#008000',
6872        greenyellow: '#adff2f',
6873        honeydew: '#f0fff0',
6874        hotpink: '#ff69b4',
6875        indianred: '#cd5c5c',
6876        indigo: '#4b0082',
6877        ivory: '#fffff0',
6878        khaki: '#f0e68c',
6879        lavender: '#e6e6fa',
6880        lavenderblush: '#fff0f5',
6881        lawngreen: '#7cfc00',
6882        lemonchiffon: '#fffacd',
6883        lightblue: '#add8e6',
6884        lightcoral: '#f08080',
6885        lightcyan: '#e0ffff',
6886        lightgoldenrodyellow: '#fafad2',
6887        lightgray: '#d3d3d3',
6888        lightgrey: '#d3d3d3',
6889        lightgreen: '#90ee90',
6890        lightpink: '#ffb6c1',
6891        lightsalmon: '#ffa07a',
6892        lightseagreen: '#20b2aa',
6893        lightskyblue: '#87cefa',
6894        lightslategray: '#789',
6895        lightslategrey: '#789',
6896        lightsteelblue: '#b0c4de',
6897        lightyellow: '#ffffe0',
6898        lime: '#0f0',
6899        limegreen: '#32cd32',
6900        linen: '#faf0e6',
6901        magenta: '#f0f',
6902        maroon: '#800000',
6903        mediumaquamarine: '#66cdaa',
6904        mediumblue: '#0000cd',
6905        mediumorchid: '#ba55d3',
6906        mediumpurple: '#9370d8',
6907        mediumseagreen: '#3cb371',
6908        mediumslateblue: '#7b68ee',
6909        mediumspringgreen: '#00fa9a',
6910        mediumturquoise: '#48d1cc',
6911        mediumvioletred: '#c71585',
6912        midnightblue: '#191970',
6913        mintcream: '#f5fffa',
6914        mistyrose: '#ffe4e1',
6915        moccasin: '#ffe4b5',
6916        navajowhite: '#ffdead',
6917        navy: '#000080',
6918        oldlace: '#fdf5e6',
6919        olive: '#808000',
6920        olivedrab: '#6b8e23',
6921        orange: '#ffa500',
6922        orangered: '#ff4500',
6923        orchid: '#da70d6',
6924        palegoldenrod: '#eee8aa',
6925        palegreen: '#98fb98',
6926        paleturquoise: '#afeeee',
6927        palevioletred: '#d87093',
6928        papayawhip: '#ffefd5',
6929        peachpuff: '#ffdab9',
6930        peru: '#cd853f',
6931        pink: '#ffc0cb',
6932        plum: '#dda0dd',
6933        powderblue: '#b0e0e6',
6934        purple: '#800080',
6935        red: '#f00',
6936        rosybrown: '#bc8f8f',
6937        royalblue: '#4169e1',
6938        saddlebrown: '#8b4513',
6939        salmon: '#fa8072',
6940        sandybrown: '#f4a460',
6941        seagreen: '#2e8b57',
6942        seashell: '#fff5ee',
6943        sienna: '#a0522d',
6944        silver: '#c0c0c0',
6945        skyblue: '#87ceeb',
6946        slateblue: '#6a5acd',
6947        slategray: '#708090',
6948        slategrey: '#708090',
6949        snow: '#fffafa',
6950        springgreen: '#00ff7f',
6951        steelblue: '#4682b4',
6952        tan: '#d2b48c',
6953        teal: '#008080',
6954        thistle: '#d8bfd8',
6955        tomato: '#ff6347',
6956        turquoise: '#40e0d0',
6957        violet: '#ee82ee',
6958        wheat: '#f5deb3',
6959        white: '#fff',
6960        whitesmoke: '#f5f5f5',
6961        yellow: '#ff0',
6962        yellowgreen: '#9acd32'
6963    };
6964    function customPalette(userPalete) {
6965        palette = userPalete;
6966    }
6967    function resetPalette() {
6968        palette = _palette;
6969    }
6970    function getColor(idx, userPalete) {
6971        idx = idx | 0;
6972        userPalete = userPalete || palette;
6973        return userPalete[idx % userPalete.length];
6974    }
6975    function customHighlight(userHighlightColor) {
6976        highlightColor = userHighlightColor;
6977    }
6978    function resetHighlight() {
6979        _highlightColor = highlightColor;
6980    }
6981    function getHighlightColor() {
6982        return highlightColor;
6983    }
6984    function getRadialGradient(x0, y0, r0, x1, y1, r1, colorList) {
6985        if (!_ctx) {
6986            _ctx = util.getContext();
6987        }
6988        var gradient = _ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);
6989        for (var i = 0, l = colorList.length; i < l; i++) {
6990            gradient.addColorStop(colorList[i][0], colorList[i][1]);
6991        }
6992        gradient.__nonRecursion = true;
6993        return gradient;
6994    }
6995    function getLinearGradient(x0, y0, x1, y1, colorList) {
6996        if (!_ctx) {
6997            _ctx = util.getContext();
6998        }
6999        var gradient = _ctx.createLinearGradient(x0, y0, x1, y1);
7000        for (var i = 0, l = colorList.length; i < l; i++) {
7001            gradient.addColorStop(colorList[i][0], colorList[i][1]);
7002        }
7003        gradient.__nonRecursion = true;
7004        return gradient;
7005    }
7006    function getStepColors(start, end, step) {
7007        start = toRGBA(start);
7008        end = toRGBA(end);
7009        start = getData(start);
7010        end = getData(end);
7011        var colors = [];
7012        var stepR = (end[0] - start[0]) / step;
7013        var stepG = (end[1] - start[1]) / step;
7014        var stepB = (end[2] - start[2]) / step;
7015        var stepA = (end[3] - start[3]) / step;
7016        for (var i = 0, r = start[0], g = start[1], b = start[2], a = start[3]; i < step; i++) {
7017            colors[i] = toColor([
7018                adjust(Math.floor(r), [
7019                    0,
7020                    255
7021                ]),
7022                adjust(Math.floor(g), [
7023                    0,
7024                    255
7025                ]),
7026                adjust(Math.floor(b), [
7027                    0,
7028                    255
7029                ]),
7030                a.toFixed(4) - 0
7031            ], 'rgba');
7032            r += stepR;
7033            g += stepG;
7034            b += stepB;
7035            a += stepA;
7036        }
7037        r = end[0];
7038        g = end[1];
7039        b = end[2];
7040        a = end[3];
7041        colors[i] = toColor([
7042            r,
7043            g,
7044            b,
7045            a
7046        ], 'rgba');
7047        return colors;
7048    }
7049    function getGradientColors(colors, step) {
7050        var ret = [];
7051        var len = colors.length;
7052        if (step === undefined) {
7053            step = 20;
7054        }
7055        if (len === 1) {
7056            ret = getStepColors(colors[0], colors[0], step);
7057        } else if (len > 1) {
7058            for (var i = 0, n = len - 1; i < n; i++) {
7059                var steps = getStepColors(colors[i], colors[i + 1], step);
7060                if (i < n - 1) {
7061                    steps.pop();
7062                }
7063                ret = ret.concat(steps);
7064            }
7065        }
7066        return ret;
7067    }
7068    function toColor(data, format) {
7069        format = format || 'rgb';
7070        if (data && (data.length === 3 || data.length === 4)) {
7071            data = map(data, function (c) {
7072                return c > 1 ? Math.ceil(c) : c;
7073            });
7074            if (format.indexOf('hex') > -1) {
7075                return '#' + ((1 << 24) + (data[0] << 16) + (data[1] << 8) + +data[2]).toString(16).slice(1);
7076            } else if (format.indexOf('hs') > -1) {
7077                var sx = map(data.slice(1, 3), function (c) {
7078                    return c + '%';
7079                });
7080                data[1] = sx[0];
7081                data[2] = sx[1];
7082            }
7083            if (format.indexOf('a') > -1) {
7084                if (data.length === 3) {
7085                    data.push(1);
7086                }
7087                data[3] = adjust(data[3], [
7088                    0,
7089                    1
7090                ]);
7091                return format + '(' + data.slice(0, 4).join(',') + ')';
7092            }
7093            return format + '(' + data.slice(0, 3).join(',') + ')';
7094        }
7095    }
7096    function toArray(color) {
7097        color = trim(color);
7098        if (color.indexOf('rgba') < 0) {
7099            color = toRGBA(color);
7100        }
7101        var data = [];
7102        var i = 0;
7103        color.replace(/[\d.]+/g, function (n) {
7104            if (i < 3) {
7105                n = n | 0;
7106            } else {
7107                n = +n;
7108            }
7109            data[i++] = n;
7110        });
7111        return data;
7112    }
7113    function convert(color, format) {
7114        if (!isCalculableColor(color)) {
7115            return color;
7116        }
7117        var data = getData(color);
7118        var alpha = data[3];
7119        if (typeof alpha === 'undefined') {
7120            alpha = 1;
7121        }
7122        if (color.indexOf('hsb') > -1) {
7123            data = _HSV_2_RGB(data);
7124        } else if (color.indexOf('hsl') > -1) {
7125            data = _HSL_2_RGB(data);
7126        }
7127        if (format.indexOf('hsb') > -1 || format.indexOf('hsv') > -1) {
7128            data = _RGB_2_HSB(data);
7129        } else if (format.indexOf('hsl') > -1) {
7130            data = _RGB_2_HSL(data);
7131        }
7132        data[3] = alpha;
7133        return toColor(data, format);
7134    }
7135    function toRGBA(color) {
7136        return convert(color, 'rgba');
7137    }
7138    function toRGB(color) {
7139        return convert(color, 'rgb');
7140    }
7141    function toHex(color) {
7142        return convert(color, 'hex');
7143    }
7144    function toHSVA(color) {
7145        return convert(color, 'hsva');
7146    }
7147    function toHSV(color) {
7148        return convert(color, 'hsv');
7149    }
7150    function toHSBA(color) {
7151        return convert(color, 'hsba');
7152    }
7153    function toHSB(color) {
7154        return convert(color, 'hsb');
7155    }
7156    function toHSLA(color) {
7157        return convert(color, 'hsla');
7158    }
7159    function toHSL(color) {
7160        return convert(color, 'hsl');
7161    }
7162    function toName(color) {
7163        for (var key in _nameColors) {
7164            if (toHex(_nameColors[key]) === toHex(color)) {
7165                return key;
7166            }
7167        }
7168        return null;
7169    }
7170    function trim(color) {
7171        return String(color).replace(/\s+/g, '');
7172    }
7173    function normalize(color) {
7174        if (_nameColors[color]) {
7175            color = _nameColors[color];
7176        }
7177        color = trim(color);
7178        color = color.replace(/hsv/i, 'hsb');
7179        if (/^#[\da-f]{3}$/i.test(color)) {
7180            color = parseInt(color.slice(1), 16);
7181            var r = (color & 3840) << 8;
7182            var g = (color & 240) << 4;
7183            var b = color & 15;
7184            color = '#' + ((1 << 24) + (r << 4) + r + (g << 4) + g + (b << 4) + b).toString(16).slice(1);
7185        }
7186        return color;
7187    }
7188    function lift(color, level) {
7189        if (!isCalculableColor(color)) {
7190            return color;
7191        }
7192        var direct = level > 0 ? 1 : -1;
7193        if (typeof level === 'undefined') {
7194            level = 0;
7195        }
7196        level = Math.abs(level) > 1 ? 1 : Math.abs(level);
7197        color = toRGB(color);
7198        var data = getData(color);
7199        for (var i = 0; i < 3; i++) {
7200            if (direct === 1) {
7201                data[i] = data[i] * (1 - level) | 0;
7202            } else {
7203                data[i] = (255 - data[i]) * level + data[i] | 0;
7204            }
7205        }
7206        return 'rgb(' + data.join(',') + ')';
7207    }
7208    function reverse(color) {
7209        if (!isCalculableColor(color)) {
7210            return color;
7211        }
7212        var data = getData(toRGBA(color));
7213        data = map(data, function (c) {
7214            return 255 - c;
7215        });
7216        return toColor(data, 'rgb');
7217    }
7218    function mix(color1, color2, weight) {
7219        if (!isCalculableColor(color1) || !isCalculableColor(color2)) {
7220            return color1;
7221        }
7222        if (typeof weight === 'undefined') {
7223            weight = 0.5;
7224        }
7225        weight = 1 - adjust(weight, [
7226            0,
7227            1
7228        ]);
7229        var w = weight * 2 - 1;
7230        var data1 = getData(toRGBA(color1));
7231        var data2 = getData(toRGBA(color2));
7232        var d = data1[3] - data2[3];
7233        var weight1 = ((w * d === -1 ? w : (w + d) / (1 + w * d)) + 1) / 2;
7234        var weight2 = 1 - weight1;
7235        var data = [];
7236        for (var i = 0; i < 3; i++) {
7237            data[i] = data1[i] * weight1 + data2[i] * weight2;
7238        }
7239        var alpha = data1[3] * weight + data2[3] * (1 - weight);
7240        alpha = Math.max(0, Math.min(1, alpha));
7241        if (data1[3] === 1 && data2[3] === 1) {
7242            return toColor(data, 'rgb');
7243        }
7244        data[3] = alpha;
7245        return toColor(data, 'rgba');
7246    }
7247    function random() {
7248        return '#' + (Math.random().toString(16) + '0000').slice(2, 8);
7249    }
7250    function getData(color) {
7251        color = normalize(color);
7252        var r = color.match(colorRegExp);
7253        if (r === null) {
7254            throw new Error('The color format error');
7255        }
7256        var d;
7257        var a;
7258        var data = [];
7259        var rgb;
7260        if (r[2]) {
7261            d = r[2].replace('#', '').split('');
7262            rgb = [
7263                d[0] + d[1],
7264                d[2] + d[3],
7265                d[4] + d[5]
7266            ];
7267            data = map(rgb, function (c) {
7268                return adjust(parseInt(c, 16), [
7269                    0,
7270                    255
7271                ]);
7272            });
7273        } else if (r[4]) {
7274            var rgba = r[4].split(',');
7275            a = rgba[3];
7276            rgb = rgba.slice(0, 3);
7277            data = map(rgb, function (c) {
7278                c = Math.floor(c.indexOf('%') > 0 ? parseInt(c, 0) * 2.55 : c);
7279                return adjust(c, [
7280                    0,
7281                    255
7282                ]);
7283            });
7284            if (typeof a !== 'undefined') {
7285                data.push(adjust(parseFloat(a), [
7286                    0,
7287                    1
7288                ]));
7289            }
7290        } else if (r[5] || r[6]) {
7291            var hsxa = (r[5] || r[6]).split(',');
7292            var h = parseInt(hsxa[0], 0) / 360;
7293            var s = hsxa[1];
7294            var x = hsxa[2];
7295            a = hsxa[3];
7296            data = map([
7297                s,
7298                x
7299            ], function (c) {
7300                return adjust(parseFloat(c) / 100, [
7301                    0,
7302                    1
7303                ]);
7304            });
7305            data.unshift(h);
7306            if (typeof a !== 'undefined') {
7307                data.push(adjust(parseFloat(a), [
7308                    0,
7309                    1
7310                ]));
7311            }
7312        }
7313        return data;
7314    }
7315    function alpha(color, a) {
7316        if (!isCalculableColor(color)) {
7317            return color;
7318        }
7319        if (a === null) {
7320            a = 1;
7321        }
7322        var data = getData(toRGBA(color));
7323        data[3] = adjust(Number(a).toFixed(4), [
7324            0,
7325            1
7326        ]);
7327        return toColor(data, 'rgba');
7328    }
7329    function map(array, fun) {
7330        if (typeof fun !== 'function') {
7331            throw new TypeError();
7332        }
7333        var len = array ? array.length : 0;
7334        for (var i = 0; i < len; i++) {
7335            array[i] = fun(array[i]);
7336        }
7337        return array;
7338    }
7339    function adjust(value, region) {
7340        if (value <= region[0]) {
7341            value = region[0];
7342        } else if (value >= region[1]) {
7343            value = region[1];
7344        }
7345        return value;
7346    }
7347    function isCalculableColor(color) {
7348        return color instanceof Array || typeof color === 'string';
7349    }
7350    function _HSV_2_RGB(data) {
7351        var H = data[0];
7352        var S = data[1];
7353        var V = data[2];
7354        var R;
7355        var G;
7356        var B;
7357        if (S === 0) {
7358            R = V * 255;
7359            G = V * 255;
7360            B = V * 255;
7361        } else {
7362            var h = H * 6;
7363            if (h === 6) {
7364                h = 0;
7365            }
7366            var i = h | 0;
7367            var v1 = V * (1 - S);
7368            var v2 = V * (1 - S * (h - i));
7369            var v3 = V * (1 - S * (1 - (h - i)));
7370            var r = 0;
7371            var g = 0;
7372            var b = 0;
7373            if (i === 0) {
7374                r = V;
7375                g = v3;
7376                b = v1;
7377            } else if (i === 1) {
7378                r = v2;
7379                g = V;
7380                b = v1;
7381            } else if (i === 2) {
7382                r = v1;
7383                g = V;
7384                b = v3;
7385            } else if (i === 3) {
7386                r = v1;
7387                g = v2;
7388                b = V;
7389            } else if (i === 4) {
7390                r = v3;
7391                g = v1;
7392                b = V;
7393            } else {
7394                r = V;
7395                g = v1;
7396                b = v2;
7397            }
7398            R = r * 255;
7399            G = g * 255;
7400            B = b * 255;
7401        }
7402        return [
7403            R,
7404            G,
7405            B
7406        ];
7407    }
7408    function _HSL_2_RGB(data) {
7409        var H = data[0];
7410        var S = data[1];
7411        var L = data[2];
7412        var R;
7413        var G;
7414        var B;
7415        if (S === 0) {
7416            R = L * 255;
7417            G = L * 255;
7418            B = L * 255;
7419        } else {
7420            var v2;
7421            if (L < 0.5) {
7422                v2 = L * (1 + S);
7423            } else {
7424                v2 = L + S - S * L;
7425            }
7426            var v1 = 2 * L - v2;
7427            R = 255 * _HUE_2_RGB(v1, v2, H + 1 / 3);
7428            G = 255 * _HUE_2_RGB(v1, v2, H);
7429            B = 255 * _HUE_2_RGB(v1, v2, H - 1 / 3);
7430        }
7431        return [
7432            R,
7433            G,
7434            B
7435        ];
7436    }
7437    function _HUE_2_RGB(v1, v2, vH) {
7438        if (vH < 0) {
7439            vH += 1;
7440        }
7441        if (vH > 1) {
7442            vH -= 1;
7443        }
7444        if (6 * vH < 1) {
7445            return v1 + (v2 - v1) * 6 * vH;
7446        }
7447        if (2 * vH < 1) {
7448            return v2;
7449        }
7450        if (3 * vH < 2) {
7451            return v1 + (v2 - v1) * (2 / 3 - vH) * 6;
7452        }
7453        return v1;
7454    }
7455    function _RGB_2_HSB(data) {
7456        var R = data[0] / 255;
7457        var G = data[1] / 255;
7458        var B = data[2] / 255;
7459        var vMin = Math.min(R, G, B);
7460        var vMax = Math.max(R, G, B);
7461        var delta = vMax - vMin;
7462        var V = vMax;
7463        var H;
7464        var S;
7465        if (delta === 0) {
7466            H = 0;
7467            S = 0;
7468        } else {
7469            S = delta / vMax;
7470            var deltaR = ((vMax - R) / 6 + delta / 2) / delta;
7471            var deltaG = ((vMax - G) / 6 + delta / 2) / delta;
7472            var deltaB = ((vMax - B) / 6 + delta / 2) / delta;
7473            if (R === vMax) {
7474                H = deltaB - deltaG;
7475            } else if (G === vMax) {
7476                H = 1 / 3 + deltaR - deltaB;
7477            } else if (B === vMax) {
7478                H = 2 / 3 + deltaG - deltaR;
7479            }
7480            if (H < 0) {
7481                H += 1;
7482            }
7483            if (H > 1) {
7484                H -= 1;
7485            }
7486        }
7487        H = H * 360;
7488        S = S * 100;
7489        V = V * 100;
7490        return [
7491            H,
7492            S,
7493            V
7494        ];
7495    }
7496    function _RGB_2_HSL(data) {
7497        var R = data[0] / 255;
7498        var G = data[1] / 255;
7499        var B = data[2] / 255;
7500        var vMin = Math.min(R, G, B);
7501        var vMax = Math.max(R, G, B);
7502        var delta = vMax - vMin;
7503        var L = (vMax + vMin) / 2;
7504        var H;
7505        var S;
7506        if (delta === 0) {
7507            H = 0;
7508            S = 0;
7509        } else {
7510            if (L < 0.5) {
7511                S = delta / (vMax + vMin);
7512            } else {
7513                S = delta / (2 - vMax - vMin);
7514            }
7515            var deltaR = ((vMax - R) / 6 + delta / 2) / delta;
7516            var deltaG = ((vMax - G) / 6 + delta / 2) / delta;
7517            var deltaB = ((vMax - B) / 6 + delta / 2) / delta;
7518            if (R === vMax) {
7519                H = deltaB - deltaG;
7520            } else if (G === vMax) {
7521                H = 1 / 3 + deltaR - deltaB;
7522            } else if (B === vMax) {
7523                H = 2 / 3 + deltaG - deltaR;
7524            }
7525            if (H < 0) {
7526                H += 1;
7527            }
7528            if (H > 1) {
7529                H -= 1;
7530            }
7531        }
7532        H = H * 360;
7533        S = S * 100;
7534        L = L * 100;
7535        return [
7536            H,
7537            S,
7538            L
7539        ];
7540    }
7541    return {
7542        customPalette: customPalette,
7543        resetPalette: resetPalette,
7544        getColor: getColor,
7545        getHighlightColor: getHighlightColor,
7546        customHighlight: customHighlight,
7547        resetHighlight: resetHighlight,
7548        getRadialGradient: getRadialGradient,
7549        getLinearGradient: getLinearGradient,
7550        getGradientColors: getGradientColors,
7551        getStepColors: getStepColors,
7552        reverse: reverse,
7553        mix: mix,
7554        lift: lift,
7555        trim: trim,
7556        random: random,
7557        toRGB: toRGB,
7558        toRGBA: toRGBA,
7559        toHex: toHex,
7560        toHSL: toHSL,
7561        toHSLA: toHSLA,
7562        toHSB: toHSB,
7563        toHSBA: toHSBA,
7564        toHSV: toHSV,
7565        toHSVA: toHSVA,
7566        toName: toName,
7567        toColor: toColor,
7568        toArray: toArray,
7569        alpha: alpha,
7570        getData: getData
7571    };
7572});define('echarts/component/timeline', [
7573    'require',
7574    './base',
7575    'zrender/shape/Rectangle',
7576    '../util/shape/Icon',
7577    '../util/shape/Chain',
7578    '../config',
7579    'zrender/tool/util',
7580    'zrender/tool/area',
7581    'zrender/tool/event',
7582    '../component'
7583], function (require) {
7584    var Base = require('./base');
7585    var RectangleShape = require('zrender/shape/Rectangle');
7586    var IconShape = require('../util/shape/Icon');
7587    var ChainShape = require('../util/shape/Chain');
7588    var ecConfig = require('../config');
7589    ecConfig.timeline = {
7590        zlevel: 0,
7591        z: 4,
7592        show: true,
7593        type: 'time',
7594        notMerge: false,
7595        realtime: true,
7596        x: 80,
7597        x2: 80,
7598        y2: 0,
7599        height: 50,
7600        backgroundColor: 'rgba(0,0,0,0)',
7601        borderColor: '#ccc',
7602        borderWidth: 0,
7603        padding: 5,
7604        controlPosition: 'left',
7605        autoPlay: false,
7606        loop: true,
7607        playInterval: 2000,
7608        lineStyle: {
7609            width: 1,
7610            color: '#666',
7611            type: 'dashed'
7612        },
7613        label: {
7614            show: true,
7615            interval: 'auto',
7616            rotate: 0,
7617            textStyle: { color: '#333' }
7618        },
7619        checkpointStyle: {
7620            symbol: 'auto',
7621            symbolSize: 'auto',
7622            color: 'auto',
7623            borderColor: 'auto',
7624            borderWidth: 'auto',
7625            label: {
7626                show: false,
7627                textStyle: { color: 'auto' }
7628            }
7629        },
7630        controlStyle: {
7631            itemSize: 15,
7632            itemGap: 5,
7633            normal: { color: '#333' },
7634            emphasis: { color: '#1e90ff' }
7635        },
7636        symbol: 'emptyDiamond',
7637        symbolSize: 4,
7638        currentIndex: 0
7639    };
7640    var zrUtil = require('zrender/tool/util');
7641    var zrArea = require('zrender/tool/area');
7642    var zrEvent = require('zrender/tool/event');
7643    function Timeline(ecTheme, messageCenter, zr, option, myChart) {
7644        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
7645        var self = this;
7646        self._onclick = function (param) {
7647            return self.__onclick(param);
7648        };
7649        self._ondrift = function (dx, dy) {
7650            return self.__ondrift(this, dx, dy);
7651        };
7652        self._ondragend = function () {
7653            return self.__ondragend();
7654        };
7655        self._setCurrentOption = function () {
7656            var timelineOption = self.timelineOption;
7657            self.currentIndex %= timelineOption.data.length;
7658            var curOption = self.options[self.currentIndex] || {};
7659            self.myChart._setOption(curOption, timelineOption.notMerge, true);
7660            self.messageCenter.dispatch(ecConfig.EVENT.TIMELINE_CHANGED, null, {
7661                currentIndex: self.currentIndex,
7662                data: timelineOption.data[self.currentIndex].name != null ? timelineOption.data[self.currentIndex].name : timelineOption.data[self.currentIndex]
7663            }, self.myChart);
7664        };
7665        self._onFrame = function () {
7666            self._setCurrentOption();
7667            self._syncHandleShape();
7668            if (self.timelineOption.autoPlay) {
7669                self.playTicket = setTimeout(function () {
7670                    self.currentIndex += 1;
7671                    if (!self.timelineOption.loop && self.currentIndex >= self.timelineOption.data.length) {
7672                        self.currentIndex = self.timelineOption.data.length - 1;
7673                        self.stop();
7674                        return;
7675                    }
7676                    self._onFrame();
7677                }, self.timelineOption.playInterval);
7678            }
7679        };
7680        this.setTheme(false);
7681        this.options = this.option.options;
7682        this.currentIndex = this.timelineOption.currentIndex % this.timelineOption.data.length;
7683        if (!this.timelineOption.notMerge && this.currentIndex !== 0) {
7684            this.options[this.currentIndex] = zrUtil.merge(this.options[this.currentIndex], this.options[0]);
7685        }
7686        if (this.timelineOption.show) {
7687            this._buildShape();
7688            this._syncHandleShape();
7689        }
7690        this._setCurrentOption();
7691        if (this.timelineOption.autoPlay) {
7692            var self = this;
7693            this.playTicket = setTimeout(function () {
7694                self.play();
7695            }, this.ecTheme.animationDuration != null ? this.ecTheme.animationDuration : ecConfig.animationDuration);
7696        }
7697    }
7698    Timeline.prototype = {
7699        type: ecConfig.COMPONENT_TYPE_TIMELINE,
7700        _buildShape: function () {
7701            this._location = this._getLocation();
7702            this._buildBackground();
7703            this._buildControl();
7704            this._chainPoint = this._getChainPoint();
7705            if (this.timelineOption.label.show) {
7706                var interval = this._getInterval();
7707                for (var i = 0, len = this._chainPoint.length; i < len; i += interval) {
7708                    this._chainPoint[i].showLabel = true;
7709                }
7710            }
7711            this._buildChain();
7712            this._buildHandle();
7713            for (var i = 0, l = this.shapeList.length; i < l; i++) {
7714                this.zr.addShape(this.shapeList[i]);
7715            }
7716        },
7717        _getLocation: function () {
7718            var timelineOption = this.timelineOption;
7719            var padding = this.reformCssArray(this.timelineOption.padding);
7720            var zrWidth = this.zr.getWidth();
7721            var x = this.parsePercent(timelineOption.x, zrWidth);
7722            var x2 = this.parsePercent(timelineOption.x2, zrWidth);
7723            var width;
7724            if (timelineOption.width == null) {
7725                width = zrWidth - x - x2;
7726                x2 = zrWidth - x2;
7727            } else {
7728                width = this.parsePercent(timelineOption.width, zrWidth);
7729                x2 = x + width;
7730            }
7731            var zrHeight = this.zr.getHeight();
7732            var height = this.parsePercent(timelineOption.height, zrHeight);
7733            var y;
7734            var y2;
7735            if (timelineOption.y != null) {
7736                y = this.parsePercent(timelineOption.y, zrHeight);
7737                y2 = y + height;
7738            } else {
7739                y2 = zrHeight - this.parsePercent(timelineOption.y2, zrHeight);
7740                y = y2 - height;
7741            }
7742            return {
7743                x: x + padding[3],
7744                y: y + padding[0],
7745                x2: x2 - padding[1],
7746                y2: y2 - padding[2],
7747                width: width - padding[1] - padding[3],
7748                height: height - padding[0] - padding[2]
7749            };
7750        },
7751        _getReformedLabel: function (idx) {
7752            var timelineOption = this.timelineOption;
7753            var data = timelineOption.data[idx].name != null ? timelineOption.data[idx].name : timelineOption.data[idx];
7754            var formatter = timelineOption.data[idx].formatter || timelineOption.label.formatter;
7755            if (formatter) {
7756                if (typeof formatter === 'function') {
7757                    data = formatter.call(this.myChart, data);
7758                } else if (typeof formatter === 'string') {
7759                    data = formatter.replace('{value}', data);
7760                }
7761            }
7762            return data;
7763        },
7764        _getInterval: function () {
7765            var chainPoint = this._chainPoint;
7766            var timelineOption = this.timelineOption;
7767            var interval = timelineOption.label.interval;
7768            if (interval === 'auto') {
7769                var fontSize = timelineOption.label.textStyle.fontSize;
7770                var data = timelineOption.data;
7771                var dataLength = timelineOption.data.length;
7772                if (dataLength > 3) {
7773                    var isEnough = false;
7774                    var labelSpace;
7775                    var labelSize;
7776                    interval = 0;
7777                    while (!isEnough && interval < dataLength) {
7778                        interval++;
7779                        isEnough = true;
7780                        for (var i = interval; i < dataLength; i += interval) {
7781                            labelSpace = chainPoint[i].x - chainPoint[i - interval].x;
7782                            if (timelineOption.label.rotate !== 0) {
7783                                labelSize = fontSize;
7784                            } else if (data[i].textStyle) {
7785                                labelSize = zrArea.getTextWidth(chainPoint[i].name, chainPoint[i].textFont);
7786                            } else {
7787                                var label = chainPoint[i].name + '';
7788                                var wLen = (label.match(/\w/g) || '').length;
7789                                var oLen = label.length - wLen;
7790                                labelSize = wLen * fontSize * 2 / 3 + oLen * fontSize;
7791                            }
7792                            if (labelSpace < labelSize) {
7793                                isEnough = false;
7794                                break;
7795                            }
7796                        }
7797                    }
7798                } else {
7799                    interval = 1;
7800                }
7801            } else {
7802                interval = interval - 0 + 1;
7803            }
7804            return interval;
7805        },
7806        _getChainPoint: function () {
7807            var timelineOption = this.timelineOption;
7808            var symbol = timelineOption.symbol.toLowerCase();
7809            var symbolSize = timelineOption.symbolSize;
7810            var rotate = timelineOption.label.rotate;
7811            var textStyle = timelineOption.label.textStyle;
7812            var textFont = this.getFont(textStyle);
7813            var dataTextStyle;
7814            var data = timelineOption.data;
7815            var x = this._location.x;
7816            var y = this._location.y + this._location.height / 4 * 3;
7817            var width = this._location.x2 - this._location.x;
7818            var len = data.length;
7819            function _getName(i) {
7820                return data[i].name != null ? data[i].name : data[i] + '';
7821            }
7822            var xList = [];
7823            if (len > 1) {
7824                var boundaryGap = width / len;
7825                boundaryGap = boundaryGap > 50 ? 50 : boundaryGap < 20 ? 5 : boundaryGap;
7826                width -= boundaryGap * 2;
7827                if (timelineOption.type === 'number') {
7828                    for (var i = 0; i < len; i++) {
7829                        xList.push(x + boundaryGap + width / (len - 1) * i);
7830                    }
7831                } else {
7832                    xList[0] = new Date(_getName(0).replace(/-/g, '/'));
7833                    xList[len - 1] = new Date(_getName(len - 1).replace(/-/g, '/')) - xList[0];
7834                    for (var i = 1; i < len; i++) {
7835                        xList[i] = x + boundaryGap + width * (new Date(_getName(i).replace(/-/g, '/')) - xList[0]) / xList[len - 1];
7836                    }
7837                    xList[0] = x + boundaryGap;
7838                }
7839            } else {
7840                xList.push(x + width / 2);
7841            }
7842            var list = [];
7843            var curSymbol;
7844            var n;
7845            var isEmpty;
7846            var textAlign;
7847            var rotation;
7848            for (var i = 0; i < len; i++) {
7849                x = xList[i];
7850                curSymbol = data[i].symbol && data[i].symbol.toLowerCase() || symbol;
7851                if (curSymbol.match('empty')) {
7852                    curSymbol = curSymbol.replace('empty', '');
7853                    isEmpty = true;
7854                } else {
7855                    isEmpty = false;
7856                }
7857                if (curSymbol.match('star')) {
7858                    n = curSymbol.replace('star', '') - 0 || 5;
7859                    curSymbol = 'star';
7860                }
7861                dataTextStyle = data[i].textStyle ? zrUtil.merge(data[i].textStyle || {}, textStyle) : textStyle;
7862                textAlign = dataTextStyle.align || 'center';
7863                if (rotate) {
7864                    textAlign = rotate > 0 ? 'right' : 'left';
7865                    rotation = [
7866                        rotate * Math.PI / 180,
7867                        x,
7868                        y - 5
7869                    ];
7870                } else {
7871                    rotation = false;
7872                }
7873                list.push({
7874                    x: x,
7875                    n: n,
7876                    isEmpty: isEmpty,
7877                    symbol: curSymbol,
7878                    symbolSize: data[i].symbolSize || symbolSize,
7879                    color: data[i].color,
7880                    borderColor: data[i].borderColor,
7881                    borderWidth: data[i].borderWidth,
7882                    name: this._getReformedLabel(i),
7883                    textColor: dataTextStyle.color,
7884                    textAlign: textAlign,
7885                    textBaseline: dataTextStyle.baseline || 'middle',
7886                    textX: x,
7887                    textY: y - (rotate ? 5 : 0),
7888                    textFont: data[i].textStyle ? this.getFont(dataTextStyle) : textFont,
7889                    rotation: rotation,
7890                    showLabel: false
7891                });
7892            }
7893            return list;
7894        },
7895        _buildBackground: function () {
7896            var timelineOption = this.timelineOption;
7897            var padding = this.reformCssArray(this.timelineOption.padding);
7898            var width = this._location.width;
7899            var height = this._location.height;
7900            if (timelineOption.borderWidth !== 0 || timelineOption.backgroundColor.replace(/\s/g, '') != 'rgba(0,0,0,0)') {
7901                this.shapeList.push(new RectangleShape({
7902                    zlevel: this.getZlevelBase(),
7903                    z: this.getZBase(),
7904                    hoverable: false,
7905                    style: {
7906                        x: this._location.x - padding[3],
7907                        y: this._location.y - padding[0],
7908                        width: width + padding[1] + padding[3],
7909                        height: height + padding[0] + padding[2],
7910                        brushType: timelineOption.borderWidth === 0 ? 'fill' : 'both',
7911                        color: timelineOption.backgroundColor,
7912                        strokeColor: timelineOption.borderColor,
7913                        lineWidth: timelineOption.borderWidth
7914                    }
7915                }));
7916            }
7917        },
7918        _buildControl: function () {
7919            var self = this;
7920            var timelineOption = this.timelineOption;
7921            var lineStyle = timelineOption.lineStyle;
7922            var controlStyle = timelineOption.controlStyle;
7923            if (timelineOption.controlPosition === 'none') {
7924                return;
7925            }
7926            var iconSize = controlStyle.itemSize;
7927            var iconGap = controlStyle.itemGap;
7928            var x;
7929            if (timelineOption.controlPosition === 'left') {
7930                x = this._location.x;
7931                this._location.x += (iconSize + iconGap) * 3;
7932            } else {
7933                x = this._location.x2 - ((iconSize + iconGap) * 3 - iconGap);
7934                this._location.x2 -= (iconSize + iconGap) * 3;
7935            }
7936            var y = this._location.y;
7937            var iconStyle = {
7938                zlevel: this.getZlevelBase(),
7939                z: this.getZBase() + 1,
7940                style: {
7941                    iconType: 'timelineControl',
7942                    symbol: 'last',
7943                    x: x,
7944                    y: y,
7945                    width: iconSize,
7946                    height: iconSize,
7947                    brushType: 'stroke',
7948                    color: controlStyle.normal.color,
7949                    strokeColor: controlStyle.normal.color,
7950                    lineWidth: lineStyle.width
7951                },
7952                highlightStyle: {
7953                    color: controlStyle.emphasis.color,
7954                    strokeColor: controlStyle.emphasis.color,
7955                    lineWidth: lineStyle.width + 1
7956                },
7957                clickable: true
7958            };
7959            this._ctrLastShape = new IconShape(iconStyle);
7960            this._ctrLastShape.onclick = function () {
7961                self.last();
7962            };
7963            this.shapeList.push(this._ctrLastShape);
7964            x += iconSize + iconGap;
7965            this._ctrPlayShape = new IconShape(zrUtil.clone(iconStyle));
7966            this._ctrPlayShape.style.brushType = 'fill';
7967            this._ctrPlayShape.style.symbol = 'play';
7968            this._ctrPlayShape.style.status = this.timelineOption.autoPlay ? 'playing' : 'stop';
7969            this._ctrPlayShape.style.x = x;
7970            this._ctrPlayShape.onclick = function () {
7971                if (self._ctrPlayShape.style.status === 'stop') {
7972                    self.play();
7973                } else {
7974                    self.stop();
7975                }
7976            };
7977            this.shapeList.push(this._ctrPlayShape);
7978            x += iconSize + iconGap;
7979            this._ctrNextShape = new IconShape(zrUtil.clone(iconStyle));
7980            this._ctrNextShape.style.symbol = 'next';
7981            this._ctrNextShape.style.x = x;
7982            this._ctrNextShape.onclick = function () {
7983                self.next();
7984            };
7985            this.shapeList.push(this._ctrNextShape);
7986        },
7987        _buildChain: function () {
7988            var timelineOption = this.timelineOption;
7989            var lineStyle = timelineOption.lineStyle;
7990            this._timelineShae = {
7991                zlevel: this.getZlevelBase(),
7992                z: this.getZBase(),
7993                style: {
7994                    x: this._location.x,
7995                    y: this.subPixelOptimize(this._location.y, lineStyle.width),
7996                    width: this._location.x2 - this._location.x,
7997                    height: this._location.height,
7998                    chainPoint: this._chainPoint,
7999                    brushType: 'both',
8000                    strokeColor: lineStyle.color,
8001                    lineWidth: lineStyle.width,
8002                    lineType: lineStyle.type
8003                },
8004                hoverable: false,
8005                clickable: true,
8006                onclick: this._onclick
8007            };
8008            this._timelineShae = new ChainShape(this._timelineShae);
8009            this.shapeList.push(this._timelineShae);
8010        },
8011        _buildHandle: function () {
8012            var curPoint = this._chainPoint[this.currentIndex];
8013            var symbolSize = curPoint.symbolSize + 1;
8014            symbolSize = symbolSize < 5 ? 5 : symbolSize;
8015            this._handleShape = {
8016                zlevel: this.getZlevelBase(),
8017                z: this.getZBase() + 1,
8018                hoverable: false,
8019                draggable: true,
8020                style: {
8021                    iconType: 'diamond',
8022                    n: curPoint.n,
8023                    x: curPoint.x - symbolSize,
8024                    y: this._location.y + this._location.height / 4 - symbolSize,
8025                    width: symbolSize * 2,
8026                    height: symbolSize * 2,
8027                    brushType: 'both',
8028                    textPosition: 'specific',
8029                    textX: curPoint.x,
8030                    textY: this._location.y - this._location.height / 4,
8031                    textAlign: 'center',
8032                    textBaseline: 'middle'
8033                },
8034                highlightStyle: {},
8035                ondrift: this._ondrift,
8036                ondragend: this._ondragend
8037            };
8038            this._handleShape = new IconShape(this._handleShape);
8039            this.shapeList.push(this._handleShape);
8040        },
8041        _syncHandleShape: function () {
8042            if (!this.timelineOption.show) {
8043                return;
8044            }
8045            var timelineOption = this.timelineOption;
8046            var cpStyle = timelineOption.checkpointStyle;
8047            var curPoint = this._chainPoint[this.currentIndex];
8048            this._handleShape.style.text = cpStyle.label.show ? curPoint.name : '';
8049            this._handleShape.style.textFont = curPoint.textFont;
8050            this._handleShape.style.n = curPoint.n;
8051            if (cpStyle.symbol === 'auto') {
8052                this._handleShape.style.iconType = curPoint.symbol != 'none' ? curPoint.symbol : 'diamond';
8053            } else {
8054                this._handleShape.style.iconType = cpStyle.symbol;
8055                if (cpStyle.symbol.match('star')) {
8056                    this._handleShape.style.n = cpStyle.symbol.replace('star', '') - 0 || 5;
8057                    this._handleShape.style.iconType = 'star';
8058                }
8059            }
8060            var symbolSize;
8061            if (cpStyle.symbolSize === 'auto') {
8062                symbolSize = curPoint.symbolSize + 2;
8063                symbolSize = symbolSize < 5 ? 5 : symbolSize;
8064            } else {
8065                symbolSize = cpStyle.symbolSize - 0;
8066            }
8067            this._handleShape.style.color = cpStyle.color === 'auto' ? curPoint.color ? curPoint.color : timelineOption.controlStyle.emphasis.color : cpStyle.color;
8068            this._handleShape.style.textColor = cpStyle.label.textStyle.color === 'auto' ? this._handleShape.style.color : cpStyle.label.textStyle.color;
8069            this._handleShape.highlightStyle.strokeColor = this._handleShape.style.strokeColor = cpStyle.borderColor === 'auto' ? curPoint.borderColor ? curPoint.borderColor : '#fff' : cpStyle.borderColor;
8070            this._handleShape.style.lineWidth = cpStyle.borderWidth === 'auto' ? curPoint.borderWidth ? curPoint.borderWidth : 0 : cpStyle.borderWidth - 0;
8071            this._handleShape.highlightStyle.lineWidth = this._handleShape.style.lineWidth + 1;
8072            this.zr.animate(this._handleShape.id, 'style').when(500, {
8073                x: curPoint.x - symbolSize,
8074                textX: curPoint.x,
8075                y: this._location.y + this._location.height / 4 - symbolSize,
8076                width: symbolSize * 2,
8077                height: symbolSize * 2
8078            }).start('ExponentialOut');
8079        },
8080        _findChainIndex: function (x) {
8081            var chainPoint = this._chainPoint;
8082            var len = chainPoint.length;
8083            if (x <= chainPoint[0].x) {
8084                return 0;
8085            } else if (x >= chainPoint[len - 1].x) {
8086                return len - 1;
8087            }
8088            for (var i = 0; i < len - 1; i++) {
8089                if (x >= chainPoint[i].x && x <= chainPoint[i + 1].x) {
8090                    return Math.abs(x - chainPoint[i].x) < Math.abs(x - chainPoint[i + 1].x) ? i : i + 1;
8091                }
8092            }
8093        },
8094        __onclick: function (param) {
8095            var x = zrEvent.getX(param.event);
8096            var newIndex = this._findChainIndex(x);
8097            if (newIndex === this.currentIndex) {
8098                return true;
8099            }
8100            this.currentIndex = newIndex;
8101            this.timelineOption.autoPlay && this.stop();
8102            clearTimeout(this.playTicket);
8103            this._onFrame();
8104        },
8105        __ondrift: function (shape, dx) {
8106            this.timelineOption.autoPlay && this.stop();
8107            var chainPoint = this._chainPoint;
8108            var len = chainPoint.length;
8109            var newIndex;
8110            if (shape.style.x + dx <= chainPoint[0].x - chainPoint[0].symbolSize) {
8111                shape.style.x = chainPoint[0].x - chainPoint[0].symbolSize;
8112                newIndex = 0;
8113            } else if (shape.style.x + dx >= chainPoint[len - 1].x - chainPoint[len - 1].symbolSize) {
8114                shape.style.x = chainPoint[len - 1].x - chainPoint[len - 1].symbolSize;
8115                newIndex = len - 1;
8116            } else {
8117                shape.style.x += dx;
8118                newIndex = this._findChainIndex(shape.style.x);
8119            }
8120            var curPoint = chainPoint[newIndex];
8121            var symbolSize = curPoint.symbolSize + 2;
8122            shape.style.iconType = curPoint.symbol;
8123            shape.style.n = curPoint.n;
8124            shape.style.textX = shape.style.x + symbolSize / 2;
8125            shape.style.y = this._location.y + this._location.height / 4 - symbolSize;
8126            shape.style.width = symbolSize * 2;
8127            shape.style.height = symbolSize * 2;
8128            shape.style.text = curPoint.name;
8129            if (newIndex === this.currentIndex) {
8130                return true;
8131            }
8132            this.currentIndex = newIndex;
8133            if (this.timelineOption.realtime) {
8134                clearTimeout(this.playTicket);
8135                var self = this;
8136                this.playTicket = setTimeout(function () {
8137                    self._setCurrentOption();
8138                }, 200);
8139            }
8140            return true;
8141        },
8142        __ondragend: function () {
8143            this.isDragend = true;
8144        },
8145        ondragend: function (param, status) {
8146            if (!this.isDragend || !param.target) {
8147                return;
8148            }
8149            !this.timelineOption.realtime && this._setCurrentOption();
8150            status.dragOut = true;
8151            status.dragIn = true;
8152            status.needRefresh = false;
8153            this.isDragend = false;
8154            this._syncHandleShape();
8155            return;
8156        },
8157        last: function () {
8158            this.timelineOption.autoPlay && this.stop();
8159            this.currentIndex -= 1;
8160            if (this.currentIndex < 0) {
8161                this.currentIndex = this.timelineOption.data.length - 1;
8162            }
8163            this._onFrame();
8164            return this.currentIndex;
8165        },
8166        next: function () {
8167            this.timelineOption.autoPlay && this.stop();
8168            this.currentIndex += 1;
8169            if (this.currentIndex >= this.timelineOption.data.length) {
8170                this.currentIndex = 0;
8171            }
8172            this._onFrame();
8173            return this.currentIndex;
8174        },
8175        play: function (targetIndex, autoPlay) {
8176            if (this._ctrPlayShape && this._ctrPlayShape.style.status != 'playing') {
8177                this._ctrPlayShape.style.status = 'playing';
8178                this.zr.modShape(this._ctrPlayShape.id);
8179                this.zr.refreshNextFrame();
8180            }
8181            this.timelineOption.autoPlay = autoPlay != null ? autoPlay : true;
8182            if (!this.timelineOption.autoPlay) {
8183                clearTimeout(this.playTicket);
8184            }
8185            this.currentIndex = targetIndex != null ? targetIndex : this.currentIndex + 1;
8186            if (this.currentIndex >= this.timelineOption.data.length) {
8187                this.currentIndex = 0;
8188            }
8189            this._onFrame();
8190            return this.currentIndex;
8191        },
8192        stop: function () {
8193            if (this._ctrPlayShape && this._ctrPlayShape.style.status != 'stop') {
8194                this._ctrPlayShape.style.status = 'stop';
8195                this.zr.modShape(this._ctrPlayShape.id);
8196                this.zr.refreshNextFrame();
8197            }
8198            this.timelineOption.autoPlay = false;
8199            clearTimeout(this.playTicket);
8200            return this.currentIndex;
8201        },
8202        resize: function () {
8203            if (this.timelineOption.show) {
8204                this.clear();
8205                this._buildShape();
8206                this._syncHandleShape();
8207            }
8208        },
8209        setTheme: function (needRefresh) {
8210            this.timelineOption = this.reformOption(zrUtil.clone(this.option.timeline));
8211            this.timelineOption.label.textStyle = this.getTextStyle(this.timelineOption.label.textStyle);
8212            this.timelineOption.checkpointStyle.label.textStyle = this.getTextStyle(this.timelineOption.checkpointStyle.label.textStyle);
8213            if (!this.myChart.canvasSupported) {
8214                this.timelineOption.realtime = false;
8215            }
8216            if (this.timelineOption.show && needRefresh) {
8217                this.clear();
8218                this._buildShape();
8219                this._syncHandleShape();
8220            }
8221        },
8222        onbeforDispose: function () {
8223            clearTimeout(this.playTicket);
8224        }
8225    };
8226    function timelineControl(ctx, style) {
8227        var lineWidth = 2;
8228        var x = style.x + lineWidth;
8229        var y = style.y + lineWidth + 2;
8230        var width = style.width - lineWidth;
8231        var height = style.height - lineWidth;
8232        var symbol = style.symbol;
8233        if (symbol === 'last') {
8234            ctx.moveTo(x + width - 2, y + height / 3);
8235            ctx.lineTo(x + width - 2, y);
8236            ctx.lineTo(x + 2, y + height / 2);
8237            ctx.lineTo(x + width - 2, y + height);
8238            ctx.lineTo(x + width - 2, y + height / 3 * 2);
8239            ctx.moveTo(x, y);
8240            ctx.lineTo(x, y);
8241        } else if (symbol === 'next') {
8242            ctx.moveTo(x + 2, y + height / 3);
8243            ctx.lineTo(x + 2, y);
8244            ctx.lineTo(x + width - 2, y + height / 2);
8245            ctx.lineTo(x + 2, y + height);
8246            ctx.lineTo(x + 2, y + height / 3 * 2);
8247            ctx.moveTo(x, y);
8248            ctx.lineTo(x, y);
8249        } else if (symbol === 'play') {
8250            if (style.status === 'stop') {
8251                ctx.moveTo(x + 2, y);
8252                ctx.lineTo(x + width - 2, y + height / 2);
8253                ctx.lineTo(x + 2, y + height);
8254                ctx.lineTo(x + 2, y);
8255            } else {
8256                var delta = style.brushType === 'both' ? 2 : 3;
8257                ctx.rect(x + 2, y, delta, height);
8258                ctx.rect(x + width - delta - 2, y, delta, height);
8259            }
8260        } else if (symbol.match('image')) {
8261            var imageLocation = '';
8262            imageLocation = symbol.replace(new RegExp('^image:\\/\\/'), '');
8263            symbol = IconShape.prototype.iconLibrary.image;
8264            symbol(ctx, {
8265                x: x,
8266                y: y,
8267                width: width,
8268                height: height,
8269                image: imageLocation
8270            });
8271        }
8272    }
8273    IconShape.prototype.iconLibrary['timelineControl'] = timelineControl;
8274    zrUtil.inherits(Timeline, Base);
8275    require('../component').define('timeline', Timeline);
8276    return Timeline;
8277});define('zrender/shape/Image', [
8278    'require',
8279    './Base',
8280    '../tool/util'
8281], function (require) {
8282    var Base = require('./Base');
8283    var ZImage = function (options) {
8284        Base.call(this, options);
8285    };
8286    ZImage.prototype = {
8287        type: 'image',
8288        brush: function (ctx, isHighlight, refreshNextFrame) {
8289            var style = this.style || {};
8290            if (isHighlight) {
8291                style = this.getHighlightStyle(style, this.highlightStyle || {});
8292            }
8293            var image = style.image;
8294            var self = this;
8295            if (!this._imageCache) {
8296                this._imageCache = {};
8297            }
8298            if (typeof image === 'string') {
8299                var src = image;
8300                if (this._imageCache[src]) {
8301                    image = this._imageCache[src];
8302                } else {
8303                    image = new Image();
8304                    image.onload = function () {
8305                        image.onload = null;
8306                        self.modSelf();
8307                        refreshNextFrame();
8308                    };
8309                    image.src = src;
8310                    this._imageCache[src] = image;
8311                }
8312            }
8313            if (image) {
8314                if (image.nodeName.toUpperCase() == 'IMG') {
8315                    if (window.ActiveXObject) {
8316                        if (image.readyState != 'complete') {
8317                            return;
8318                        }
8319                    } else {
8320                        if (!image.complete) {
8321                            return;
8322                        }
8323                    }
8324                }
8325                var width = style.width || image.width;
8326                var height = style.height || image.height;
8327                var x = style.x;
8328                var y = style.y;
8329                if (!image.width || !image.height) {
8330                    return;
8331                }
8332                ctx.save();
8333                this.doClip(ctx);
8334                this.setContext(ctx, style);
8335                this.setTransform(ctx);
8336                if (style.sWidth && style.sHeight) {
8337                    var sx = style.sx || 0;
8338                    var sy = style.sy || 0;
8339                    ctx.drawImage(image, sx, sy, style.sWidth, style.sHeight, x, y, width, height);
8340                } else if (style.sx && style.sy) {
8341                    var sx = style.sx;
8342                    var sy = style.sy;
8343                    var sWidth = width - sx;
8344                    var sHeight = height - sy;
8345                    ctx.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
8346                } else {
8347                    ctx.drawImage(image, x, y, width, height);
8348                }
8349                if (!style.width) {
8350                    style.width = width;
8351                }
8352                if (!style.height) {
8353                    style.height = height;
8354                }
8355                if (!this.style.width) {
8356                    this.style.width = width;
8357                }
8358                if (!this.style.height) {
8359                    this.style.height = height;
8360                }
8361                this.drawText(ctx, style, this.style);
8362                ctx.restore();
8363            }
8364        },
8365        getRect: function (style) {
8366            return {
8367                x: style.x,
8368                y: style.y,
8369                width: style.width,
8370                height: style.height
8371            };
8372        },
8373        clearCache: function () {
8374            this._imageCache = {};
8375        }
8376    };
8377    require('../tool/util').inherits(ZImage, Base);
8378    return ZImage;
8379});define('zrender/loadingEffect/Bar', [
8380    'require',
8381    './Base',
8382    '../tool/util',
8383    '../tool/color',
8384    '../shape/Rectangle'
8385], function (require) {
8386    var Base = require('./Base');
8387    var util = require('../tool/util');
8388    var zrColor = require('../tool/color');
8389    var RectangleShape = require('../shape/Rectangle');
8390    function Bar(options) {
8391        Base.call(this, options);
8392    }
8393    util.inherits(Bar, Base);
8394    Bar.prototype._start = function (addShapeHandle, refreshHandle) {
8395        var options = util.merge(this.options, {
8396            textStyle: { color: '#888' },
8397            backgroundColor: 'rgba(250, 250, 250, 0.8)',
8398            effectOption: {
8399                x: 0,
8400                y: this.canvasHeight / 2 - 30,
8401                width: this.canvasWidth,
8402                height: 5,
8403                brushType: 'fill',
8404                timeInterval: 100
8405            }
8406        });
8407        var textShape = this.createTextShape(options.textStyle);
8408        var background = this.createBackgroundShape(options.backgroundColor);
8409        var effectOption = options.effectOption;
8410        var barShape = new RectangleShape({ highlightStyle: util.clone(effectOption) });
8411        barShape.highlightStyle.color = effectOption.color || zrColor.getLinearGradient(effectOption.x, effectOption.y, effectOption.x + effectOption.width, effectOption.y + effectOption.height, [
8412            [
8413                0,
8414                '#ff6400'
8415            ],
8416            [
8417                0.5,
8418                '#ffe100'
8419            ],
8420            [
8421                1,
8422                '#b1ff00'
8423            ]
8424        ]);
8425        if (options.progress != null) {
8426            addShapeHandle(background);
8427            barShape.highlightStyle.width = this.adjust(options.progress, [
8428                0,
8429                1
8430            ]) * options.effectOption.width;
8431            addShapeHandle(barShape);
8432            addShapeHandle(textShape);
8433            refreshHandle();
8434            return;
8435        } else {
8436            barShape.highlightStyle.width = 0;
8437            return setInterval(function () {
8438                addShapeHandle(background);
8439                if (barShape.highlightStyle.width < effectOption.width) {
8440                    barShape.highlightStyle.width += 8;
8441                } else {
8442                    barShape.highlightStyle.width = 0;
8443                }
8444                addShapeHandle(barShape);
8445                addShapeHandle(textShape);
8446                refreshHandle();
8447            }, effectOption.timeInterval);
8448        }
8449    };
8450    return Bar;
8451});define('zrender/loadingEffect/Bubble', [
8452    'require',
8453    './Base',
8454    '../tool/util',
8455    '../tool/color',
8456    '../shape/Circle'
8457], function (require) {
8458    var Base = require('./Base');
8459    var util = require('../tool/util');
8460    var zrColor = require('../tool/color');
8461    var CircleShape = require('../shape/Circle');
8462    function Bubble(options) {
8463        Base.call(this, options);
8464    }
8465    util.inherits(Bubble, Base);
8466    Bubble.prototype._start = function (addShapeHandle, refreshHandle) {
8467        var options = util.merge(this.options, {
8468            textStyle: { color: '#888' },
8469            backgroundColor: 'rgba(250, 250, 250, 0.8)',
8470            effect: {
8471                n: 50,
8472                lineWidth: 2,
8473                brushType: 'stroke',
8474                color: 'random',
8475                timeInterval: 100
8476            }
8477        });
8478        var textShape = this.createTextShape(options.textStyle);
8479        var background = this.createBackgroundShape(options.backgroundColor);
8480        var effectOption = options.effect;
8481        var n = effectOption.n;
8482        var brushType = effectOption.brushType;
8483        var lineWidth = effectOption.lineWidth;
8484        var shapeList = [];
8485        var canvasWidth = this.canvasWidth;
8486        var canvasHeight = this.canvasHeight;
8487        for (var i = 0; i < n; i++) {
8488            var color = effectOption.color == 'random' ? zrColor.alpha(zrColor.random(), 0.3) : effectOption.color;
8489            shapeList[i] = new CircleShape({
8490                highlightStyle: {
8491                    x: Math.ceil(Math.random() * canvasWidth),
8492                    y: Math.ceil(Math.random() * canvasHeight),
8493                    r: Math.ceil(Math.random() * 40),
8494                    brushType: brushType,
8495                    color: color,
8496                    strokeColor: color,
8497                    lineWidth: lineWidth
8498                },
8499                animationY: Math.ceil(Math.random() * 20)
8500            });
8501        }
8502        return setInterval(function () {
8503            addShapeHandle(background);
8504            for (var i = 0; i < n; i++) {
8505                var style = shapeList[i].highlightStyle;
8506                if (style.y - shapeList[i].animationY + style.r <= 0) {
8507                    shapeList[i].highlightStyle.y = canvasHeight + style.r;
8508                    shapeList[i].highlightStyle.x = Math.ceil(Math.random() * canvasWidth);
8509                }
8510                shapeList[i].highlightStyle.y -= shapeList[i].animationY;
8511                addShapeHandle(shapeList[i]);
8512            }
8513            addShapeHandle(textShape);
8514            refreshHandle();
8515        }, effectOption.timeInterval);
8516    };
8517    return Bubble;
8518});define('zrender/loadingEffect/DynamicLine', [
8519    'require',
8520    './Base',
8521    '../tool/util',
8522    '../tool/color',
8523    '../shape/Line'
8524], function (require) {
8525    var Base = require('./Base');
8526    var util = require('../tool/util');
8527    var zrColor = require('../tool/color');
8528    var LineShape = require('../shape/Line');
8529    function DynamicLine(options) {
8530        Base.call(this, options);
8531    }
8532    util.inherits(DynamicLine, Base);
8533    DynamicLine.prototype._start = function (addShapeHandle, refreshHandle) {
8534        var options = util.merge(this.options, {
8535            textStyle: { color: '#fff' },
8536            backgroundColor: 'rgba(0, 0, 0, 0.8)',
8537            effectOption: {
8538                n: 30,
8539                lineWidth: 1,
8540                color: 'random',
8541                timeInterval: 100
8542            }
8543        });
8544        var textShape = this.createTextShape(options.textStyle);
8545        var background = this.createBackgroundShape(options.backgroundColor);
8546        var effectOption = options.effectOption;
8547        var n = effectOption.n;
8548        var lineWidth = effectOption.lineWidth;
8549        var shapeList = [];
8550        var canvasWidth = this.canvasWidth;
8551        var canvasHeight = this.canvasHeight;
8552        for (var i = 0; i < n; i++) {
8553            var xStart = -Math.ceil(Math.random() * 1000);
8554            var len = Math.ceil(Math.random() * 400);
8555            var pos = Math.ceil(Math.random() * canvasHeight);
8556            var color = effectOption.color == 'random' ? zrColor.random() : effectOption.color;
8557            shapeList[i] = new LineShape({
8558                highlightStyle: {
8559                    xStart: xStart,
8560                    yStart: pos,
8561                    xEnd: xStart + len,
8562                    yEnd: pos,
8563                    strokeColor: color,
8564                    lineWidth: lineWidth
8565                },
8566                animationX: Math.ceil(Math.random() * 100),
8567                len: len
8568            });
8569        }
8570        return setInterval(function () {
8571            addShapeHandle(background);
8572            for (var i = 0; i < n; i++) {
8573                var style = shapeList[i].highlightStyle;
8574                if (style.xStart >= canvasWidth) {
8575                    shapeList[i].len = Math.ceil(Math.random() * 400);
8576                    style.xStart = -400;
8577                    style.xEnd = -400 + shapeList[i].len;
8578                    style.yStart = Math.ceil(Math.random() * canvasHeight);
8579                    style.yEnd = style.yStart;
8580                }
8581                style.xStart += shapeList[i].animationX;
8582                style.xEnd += shapeList[i].animationX;
8583                addShapeHandle(shapeList[i]);
8584            }
8585            addShapeHandle(textShape);
8586            refreshHandle();
8587        }, effectOption.timeInterval);
8588    };
8589    return DynamicLine;
8590});define('zrender/loadingEffect/Ring', [
8591    'require',
8592    './Base',
8593    '../tool/util',
8594    '../tool/color',
8595    '../shape/Ring',
8596    '../shape/Sector'
8597], function (require) {
8598    var Base = require('./Base');
8599    var util = require('../tool/util');
8600    var zrColor = require('../tool/color');
8601    var RingShape = require('../shape/Ring');
8602    var SectorShape = require('../shape/Sector');
8603    function Ring(options) {
8604        Base.call(this, options);
8605    }
8606    util.inherits(Ring, Base);
8607    Ring.prototype._start = function (addShapeHandle, refreshHandle) {
8608        var options = util.merge(this.options, {
8609            textStyle: { color: '#07a' },
8610            backgroundColor: 'rgba(250, 250, 250, 0.8)',
8611            effect: {
8612                x: this.canvasWidth / 2,
8613                y: this.canvasHeight / 2,
8614                r0: 60,
8615                r: 100,
8616                color: '#bbdcff',
8617                brushType: 'fill',
8618                textPosition: 'inside',
8619                textFont: 'normal 30px verdana',
8620                textColor: 'rgba(30, 144, 255, 0.6)',
8621                timeInterval: 100
8622            }
8623        });
8624        var effectOption = options.effect;
8625        var textStyle = options.textStyle;
8626        if (textStyle.x == null) {
8627            textStyle.x = effectOption.x;
8628        }
8629        if (textStyle.y == null) {
8630            textStyle.y = effectOption.y + (effectOption.r0 + effectOption.r) / 2 - 5;
8631        }
8632        var textShape = this.createTextShape(options.textStyle);
8633        var background = this.createBackgroundShape(options.backgroundColor);
8634        var x = effectOption.x;
8635        var y = effectOption.y;
8636        var r0 = effectOption.r0 + 6;
8637        var r = effectOption.r - 6;
8638        var color = effectOption.color;
8639        var darkColor = zrColor.lift(color, 0.1);
8640        var shapeRing = new RingShape({ highlightStyle: util.clone(effectOption) });
8641        var shapeList = [];
8642        var clolrList = zrColor.getGradientColors([
8643            '#ff6400',
8644            '#ffe100',
8645            '#97ff00'
8646        ], 25);
8647        var preAngle = 15;
8648        var endAngle = 240;
8649        for (var i = 0; i < 16; i++) {
8650            shapeList.push(new SectorShape({
8651                highlightStyle: {
8652                    x: x,
8653                    y: y,
8654                    r0: r0,
8655                    r: r,
8656                    startAngle: endAngle - preAngle,
8657                    endAngle: endAngle,
8658                    brushType: 'fill',
8659                    color: darkColor
8660                },
8661                _color: zrColor.getLinearGradient(x + r0 * Math.cos(endAngle, true), y - r0 * Math.sin(endAngle, true), x + r0 * Math.cos(endAngle - preAngle, true), y - r0 * Math.sin(endAngle - preAngle, true), [
8662                    [
8663                        0,
8664                        clolrList[i * 2]
8665                    ],
8666                    [
8667                        1,
8668                        clolrList[i * 2 + 1]
8669                    ]
8670                ])
8671            }));
8672            endAngle -= preAngle;
8673        }
8674        endAngle = 360;
8675        for (var i = 0; i < 4; i++) {
8676            shapeList.push(new SectorShape({
8677                highlightStyle: {
8678                    x: x,
8679                    y: y,
8680                    r0: r0,
8681                    r: r,
8682                    startAngle: endAngle - preAngle,
8683                    endAngle: endAngle,
8684                    brushType: 'fill',
8685                    color: darkColor
8686                },
8687                _color: zrColor.getLinearGradient(x + r0 * Math.cos(endAngle, true), y - r0 * Math.sin(endAngle, true), x + r0 * Math.cos(endAngle - preAngle, true), y - r0 * Math.sin(endAngle - preAngle, true), [
8688                    [
8689                        0,
8690                        clolrList[i * 2 + 32]
8691                    ],
8692                    [
8693                        1,
8694                        clolrList[i * 2 + 33]
8695                    ]
8696                ])
8697            }));
8698            endAngle -= preAngle;
8699        }
8700        var n = 0;
8701        if (options.progress != null) {
8702            addShapeHandle(background);
8703            n = this.adjust(options.progress, [
8704                0,
8705                1
8706            ]).toFixed(2) * 100 / 5;
8707            shapeRing.highlightStyle.text = n * 5 + '%';
8708            addShapeHandle(shapeRing);
8709            for (var i = 0; i < 20; i++) {
8710                shapeList[i].highlightStyle.color = i < n ? shapeList[i]._color : darkColor;
8711                addShapeHandle(shapeList[i]);
8712            }
8713            addShapeHandle(textShape);
8714            refreshHandle();
8715            return;
8716        }
8717        return setInterval(function () {
8718            addShapeHandle(background);
8719            n += n >= 20 ? -20 : 1;
8720            addShapeHandle(shapeRing);
8721            for (var i = 0; i < 20; i++) {
8722                shapeList[i].highlightStyle.color = i < n ? shapeList[i]._color : darkColor;
8723                addShapeHandle(shapeList[i]);
8724            }
8725            addShapeHandle(textShape);
8726            refreshHandle();
8727        }, effectOption.timeInterval);
8728    };
8729    return Ring;
8730});define('zrender/loadingEffect/Spin', [
8731    'require',
8732    './Base',
8733    '../tool/util',
8734    '../tool/color',
8735    '../tool/area',
8736    '../shape/Sector'
8737], function (require) {
8738    var Base = require('./Base');
8739    var util = require('../tool/util');
8740    var zrColor = require('../tool/color');
8741    var zrArea = require('../tool/area');
8742    var SectorShape = require('../shape/Sector');
8743    function Spin(options) {
8744        Base.call(this, options);
8745    }
8746    util.inherits(Spin, Base);
8747    Spin.prototype._start = function (addShapeHandle, refreshHandle) {
8748        var options = util.merge(this.options, {
8749            textStyle: {
8750                color: '#fff',
8751                textAlign: 'start'
8752            },
8753            backgroundColor: 'rgba(0, 0, 0, 0.8)'
8754        });
8755        var textShape = this.createTextShape(options.textStyle);
8756        var textGap = 10;
8757        var textWidth = zrArea.getTextWidth(textShape.highlightStyle.text, textShape.highlightStyle.textFont);
8758        var textHeight = zrArea.getTextHeight(textShape.highlightStyle.text, textShape.highlightStyle.textFont);
8759        var effectOption = util.merge(this.options.effect || {}, {
8760            r0: 9,
8761            r: 15,
8762            n: 18,
8763            color: '#fff',
8764            timeInterval: 100
8765        });
8766        var location = this.getLocation(this.options.textStyle, textWidth + textGap + effectOption.r * 2, Math.max(effectOption.r * 2, textHeight));
8767        effectOption.x = location.x + effectOption.r;
8768        effectOption.y = textShape.highlightStyle.y = location.y + location.height / 2;
8769        textShape.highlightStyle.x = effectOption.x + effectOption.r + textGap;
8770        var background = this.createBackgroundShape(options.backgroundColor);
8771        var n = effectOption.n;
8772        var x = effectOption.x;
8773        var y = effectOption.y;
8774        var r0 = effectOption.r0;
8775        var r = effectOption.r;
8776        var color = effectOption.color;
8777        var shapeList = [];
8778        var preAngle = Math.round(180 / n);
8779        for (var i = 0; i < n; i++) {
8780            shapeList[i] = new SectorShape({
8781                highlightStyle: {
8782                    x: x,
8783                    y: y,
8784                    r0: r0,
8785                    r: r,
8786                    startAngle: preAngle * i * 2,
8787                    endAngle: preAngle * i * 2 + preAngle,
8788                    color: zrColor.alpha(color, (i + 1) / n),
8789                    brushType: 'fill'
8790                }
8791            });
8792        }
8793        var pos = [
8794            0,
8795            x,
8796            y
8797        ];
8798        return setInterval(function () {
8799            addShapeHandle(background);
8800            pos[0] -= 0.3;
8801            for (var i = 0; i < n; i++) {
8802                shapeList[i].rotation = pos;
8803                addShapeHandle(shapeList[i]);
8804            }
8805            addShapeHandle(textShape);
8806            refreshHandle();
8807        }, effectOption.timeInterval);
8808    };
8809    return Spin;
8810});define('zrender/loadingEffect/Whirling', [
8811    'require',
8812    './Base',
8813    '../tool/util',
8814    '../tool/area',
8815    '../shape/Ring',
8816    '../shape/Droplet',
8817    '../shape/Circle'
8818], function (require) {
8819    var Base = require('./Base');
8820    var util = require('../tool/util');
8821    var zrArea = require('../tool/area');
8822    var RingShape = require('../shape/Ring');
8823    var DropletShape = require('../shape/Droplet');
8824    var CircleShape = require('../shape/Circle');
8825    function Whirling(options) {
8826        Base.call(this, options);
8827    }
8828    util.inherits(Whirling, Base);
8829    Whirling.prototype._start = function (addShapeHandle, refreshHandle) {
8830        var options = util.merge(this.options, {
8831            textStyle: {
8832                color: '#888',
8833                textAlign: 'start'
8834            },
8835            backgroundColor: 'rgba(250, 250, 250, 0.8)'
8836        });
8837        var textShape = this.createTextShape(options.textStyle);
8838        var textGap = 10;
8839        var textWidth = zrArea.getTextWidth(textShape.highlightStyle.text, textShape.highlightStyle.textFont);
8840        var textHeight = zrArea.getTextHeight(textShape.highlightStyle.text, textShape.highlightStyle.textFont);
8841        var effectOption = util.merge(this.options.effect || {}, {
8842            r: 18,
8843            colorIn: '#fff',
8844            colorOut: '#555',
8845            colorWhirl: '#6cf',
8846            timeInterval: 50
8847        });
8848        var location = this.getLocation(this.options.textStyle, textWidth + textGap + effectOption.r * 2, Math.max(effectOption.r * 2, textHeight));
8849        effectOption.x = location.x + effectOption.r;
8850        effectOption.y = textShape.highlightStyle.y = location.y + location.height / 2;
8851        textShape.highlightStyle.x = effectOption.x + effectOption.r + textGap;
8852        var background = this.createBackgroundShape(options.backgroundColor);
8853        var droplet = new DropletShape({
8854            highlightStyle: {
8855                a: Math.round(effectOption.r / 2),
8856                b: Math.round(effectOption.r - effectOption.r / 6),
8857                brushType: 'fill',
8858                color: effectOption.colorWhirl
8859            }
8860        });
8861        var circleIn = new CircleShape({
8862            highlightStyle: {
8863                r: Math.round(effectOption.r / 6),
8864                brushType: 'fill',
8865                color: effectOption.colorIn
8866            }
8867        });
8868        var circleOut = new RingShape({
8869            highlightStyle: {
8870                r0: Math.round(effectOption.r - effectOption.r / 3),
8871                r: effectOption.r,
8872                brushType: 'fill',
8873                color: effectOption.colorOut
8874            }
8875        });
8876        var pos = [
8877            0,
8878            effectOption.x,
8879            effectOption.y
8880        ];
8881        droplet.highlightStyle.x = circleIn.highlightStyle.x = circleOut.highlightStyle.x = pos[1];
8882        droplet.highlightStyle.y = circleIn.highlightStyle.y = circleOut.highlightStyle.y = pos[2];
8883        return setInterval(function () {
8884            addShapeHandle(background);
8885            addShapeHandle(circleOut);
8886            pos[0] -= 0.3;
8887            droplet.rotation = pos;
8888            addShapeHandle(droplet);
8889            addShapeHandle(circleIn);
8890            addShapeHandle(textShape);
8891            refreshHandle();
8892        }, effectOption.timeInterval);
8893    };
8894    return Whirling;
8895});define('echarts/theme/macarons', [], function () {
8896    var theme = {
8897        color: [
8898            '#2ec7c9',
8899            '#b6a2de',
8900            '#5ab1ef',
8901            '#ffb980',
8902            '#d87a80',
8903            '#8d98b3',
8904            '#e5cf0d',
8905            '#97b552',
8906            '#95706d',
8907            '#dc69aa',
8908            '#07a2a4',
8909            '#9a7fd1',
8910            '#588dd5',
8911            '#f5994e',
8912            '#c05050',
8913            '#59678c',
8914            '#c9ab00',
8915            '#7eb00a',
8916            '#6f5553',
8917            '#c14089'
8918        ],
8919        title: {
8920            textStyle: {
8921                fontWeight: 'normal',
8922                color: '#008acd'
8923            }
8924        },
8925        dataRange: {
8926            itemWidth: 15,
8927            color: [
8928                '#5ab1ef',
8929                '#e0ffff'
8930            ]
8931        },
8932        toolbox: {
8933            color: [
8934                '#1e90ff',
8935                '#1e90ff',
8936                '#1e90ff',
8937                '#1e90ff'
8938            ],
8939            effectiveColor: '#ff4500'
8940        },
8941        tooltip: {
8942            backgroundColor: 'rgba(50,50,50,0.5)',
8943            axisPointer: {
8944                type: 'line',
8945                lineStyle: { color: '#008acd' },
8946                crossStyle: { color: '#008acd' },
8947                shadowStyle: { color: 'rgba(200,200,200,0.2)' }
8948            }
8949        },
8950        dataZoom: {
8951            dataBackgroundColor: '#efefff',
8952            fillerColor: 'rgba(182,162,222,0.2)',
8953            handleColor: '#008acd'
8954        },
8955        grid: { borderColor: '#eee' },
8956        categoryAxis: {
8957            axisLine: { lineStyle: { color: '#008acd' } },
8958            splitLine: { lineStyle: { color: ['#eee'] } }
8959        },
8960        valueAxis: {
8961            axisLine: { lineStyle: { color: '#008acd' } },
8962            splitArea: {
8963                show: true,
8964                areaStyle: {
8965                    color: [
8966                        'rgba(250,250,250,0.1)',
8967                        'rgba(200,200,200,0.1)'
8968                    ]
8969                }
8970            },
8971            splitLine: { lineStyle: { color: ['#eee'] } }
8972        },
8973        polar: {
8974            axisLine: { lineStyle: { color: '#ddd' } },
8975            splitArea: {
8976                show: true,
8977                areaStyle: {
8978                    color: [
8979                        'rgba(250,250,250,0.2)',
8980                        'rgba(200,200,200,0.2)'
8981                    ]
8982                }
8983            },
8984            splitLine: { lineStyle: { color: '#ddd' } }
8985        },
8986        timeline: {
8987            lineStyle: { color: '#008acd' },
8988            controlStyle: {
8989                normal: { color: '#008acd' },
8990                emphasis: { color: '#008acd' }
8991            },
8992            symbol: 'emptyCircle',
8993            symbolSize: 3
8994        },
8995        bar: {
8996            itemStyle: {
8997                normal: { barBorderRadius: 5 },
8998                emphasis: { barBorderRadius: 5 }
8999            }
9000        },
9001        line: {
9002            smooth: true,
9003            symbol: 'emptyCircle',
9004            symbolSize: 3
9005        },
9006        k: {
9007            itemStyle: {
9008                normal: {
9009                    color: '#d87a80',
9010                    color0: '#2ec7c9',
9011                    lineStyle: {
9012                        color: '#d87a80',
9013                        color0: '#2ec7c9'
9014                    }
9015                }
9016            }
9017        },
9018        scatter: {
9019            symbol: 'circle',
9020            symbolSize: 4
9021        },
9022        radar: {
9023            symbol: 'emptyCircle',
9024            symbolSize: 3
9025        },
9026        map: {
9027            itemStyle: {
9028                normal: {
9029                    areaStyle: { color: '#ddd' },
9030                    label: { textStyle: { color: '#d87a80' } }
9031                },
9032                emphasis: { areaStyle: { color: '#fe994e' } }
9033            }
9034        },
9035        force: { itemStyle: { normal: { linkStyle: { color: '#1e90ff' } } } },
9036        chord: {
9037            itemStyle: {
9038                normal: {
9039                    borderWidth: 1,
9040                    borderColor: 'rgba(128, 128, 128, 0.5)',
9041                    chordStyle: { lineStyle: { color: 'rgba(128, 128, 128, 0.5)' } }
9042                },
9043                emphasis: {
9044                    borderWidth: 1,
9045                    borderColor: 'rgba(128, 128, 128, 0.5)',
9046                    chordStyle: { lineStyle: { color: 'rgba(128, 128, 128, 0.5)' } }
9047                }
9048            }
9049        },
9050        gauge: {
9051            axisLine: {
9052                lineStyle: {
9053                    color: [
9054                        [
9055                            0.2,
9056                            '#2ec7c9'
9057                        ],
9058                        [
9059                            0.8,
9060                            '#5ab1ef'
9061                        ],
9062                        [
9063                            1,
9064                            '#d87a80'
9065                        ]
9066                    ],
9067                    width: 10
9068                }
9069            },
9070            axisTick: {
9071                splitNumber: 10,
9072                length: 15,
9073                lineStyle: { color: 'auto' }
9074            },
9075            splitLine: {
9076                length: 22,
9077                lineStyle: { color: 'auto' }
9078            },
9079            pointer: { width: 5 }
9080        },
9081        textStyle: { fontFamily: '微软雅黑, Arial, Verdana, sans-serif' }
9082    };
9083    return theme;
9084});define('echarts/theme/infographic', [], function () {
9085    var theme = {
9086        color: [
9087            '#C1232B',
9088            '#B5C334',
9089            '#FCCE10',
9090            '#E87C25',
9091            '#27727B',
9092            '#FE8463',
9093            '#9BCA63',
9094            '#FAD860',
9095            '#F3A43B',
9096            '#60C0DD',
9097            '#D7504B',
9098            '#C6E579',
9099            '#F4E001',
9100            '#F0805A',
9101            '#26C0C0'
9102        ],
9103        title: {
9104            textStyle: {
9105                fontWeight: 'normal',
9106                color: '#27727B'
9107            }
9108        },
9109        dataRange: {
9110            x: 'right',
9111            y: 'center',
9112            itemWidth: 5,
9113            itemHeight: 25,
9114            color: [
9115                '#C1232B',
9116                '#FCCE10'
9117            ]
9118        },
9119        toolbox: {
9120            color: [
9121                '#C1232B',
9122                '#B5C334',
9123                '#FCCE10',
9124                '#E87C25',
9125                '#27727B',
9126                '#FE8463',
9127                '#9BCA63',
9128                '#FAD860',
9129                '#F3A43B',
9130                '#60C0DD'
9131            ],
9132            effectiveColor: '#ff4500'
9133        },
9134        tooltip: {
9135            backgroundColor: 'rgba(50,50,50,0.5)',
9136            axisPointer: {
9137                type: 'line',
9138                lineStyle: {
9139                    color: '#27727B',
9140                    type: 'dashed'
9141                },
9142                crossStyle: { color: '#27727B' },
9143                shadowStyle: { color: 'rgba(200,200,200,0.3)' }
9144            }
9145        },
9146        dataZoom: {
9147            dataBackgroundColor: 'rgba(181,195,52,0.3)',
9148            fillerColor: 'rgba(181,195,52,0.2)',
9149            handleColor: '#27727B'
9150        },
9151        grid: { borderWidth: 0 },
9152        categoryAxis: {
9153            axisLine: { lineStyle: { color: '#27727B' } },
9154            splitLine: { show: false }
9155        },
9156        valueAxis: {
9157            axisLine: { show: false },
9158            splitArea: { show: false },
9159            splitLine: {
9160                lineStyle: {
9161                    color: ['#ccc'],
9162                    type: 'dashed'
9163                }
9164            }
9165        },
9166        polar: {
9167            axisLine: { lineStyle: { color: '#ddd' } },
9168            splitArea: {
9169                show: true,
9170                areaStyle: {
9171                    color: [
9172                        'rgba(250,250,250,0.2)',
9173                        'rgba(200,200,200,0.2)'
9174                    ]
9175                }
9176            },
9177            splitLine: { lineStyle: { color: '#ddd' } }
9178        },
9179        timeline: {
9180            lineStyle: { color: '#27727B' },
9181            controlStyle: {
9182                normal: { color: '#27727B' },
9183                emphasis: { color: '#27727B' }
9184            },
9185            symbol: 'emptyCircle',
9186            symbolSize: 3
9187        },
9188        line: {
9189            itemStyle: {
9190                normal: {
9191                    borderWidth: 2,
9192                    borderColor: '#fff',
9193                    lineStyle: { width: 3 }
9194                },
9195                emphasis: { borderWidth: 0 }
9196            },
9197            symbol: 'circle',
9198            symbolSize: 3.5
9199        },
9200        k: {
9201            itemStyle: {
9202                normal: {
9203                    color: '#C1232B',
9204                    color0: '#B5C334',
9205                    lineStyle: {
9206                        width: 1,
9207                        color: '#C1232B',
9208                        color0: '#B5C334'
9209                    }
9210                }
9211            }
9212        },
9213        scatter: {
9214            itemStyle: {
9215                normal: {
9216                    borderWidth: 1,
9217                    borderColor: 'rgba(200,200,200,0.5)'
9218                },
9219                emphasis: { borderWidth: 0 }
9220            },
9221            symbol: 'star4',
9222            symbolSize: 4
9223        },
9224        radar: {
9225            symbol: 'emptyCircle',
9226            symbolSize: 3
9227        },
9228        map: {
9229            itemStyle: {
9230                normal: {
9231                    areaStyle: { color: '#ddd' },
9232                    label: { textStyle: { color: '#C1232B' } }
9233                },
9234                emphasis: {
9235                    areaStyle: { color: '#fe994e' },
9236                    label: { textStyle: { color: 'rgb(100,0,0)' } }
9237                }
9238            }
9239        },
9240        force: { itemStyle: { normal: { linkStyle: { color: '#27727B' } } } },
9241        chord: {
9242            itemStyle: {
9243                normal: {
9244                    borderWidth: 1,
9245                    borderColor: 'rgba(128, 128, 128, 0.5)',
9246                    chordStyle: { lineStyle: { color: 'rgba(128, 128, 128, 0.5)' } }
9247                },
9248                emphasis: {
9249                    borderWidth: 1,
9250                    borderColor: 'rgba(128, 128, 128, 0.5)',
9251                    chordStyle: { lineStyle: { color: 'rgba(128, 128, 128, 0.5)' } }
9252                }
9253            }
9254        },
9255        gauge: {
9256            center: [
9257                '50%',
9258                '80%'
9259            ],
9260            radius: '100%',
9261            startAngle: 180,
9262            endAngle: 0,
9263            axisLine: {
9264                show: true,
9265                lineStyle: {
9266                    color: [
9267                        [
9268                            0.2,
9269                            '#B5C334'
9270                        ],
9271                        [
9272                            0.8,
9273                            '#27727B'
9274                        ],
9275                        [
9276                            1,
9277                            '#C1232B'
9278                        ]
9279                    ],
9280                    width: '40%'
9281                }
9282            },
9283            axisTick: {
9284                splitNumber: 2,
9285                length: 5,
9286                lineStyle: { color: '#fff' }
9287            },
9288            axisLabel: {
9289                textStyle: {
9290                    color: '#fff',
9291                    fontWeight: 'bolder'
9292                }
9293            },
9294            splitLine: {
9295                length: '5%',
9296                lineStyle: { color: '#fff' }
9297            },
9298            pointer: {
9299                width: '40%',
9300                length: '80%',
9301                color: '#fff'
9302            },
9303            title: {
9304                offsetCenter: [
9305                    0,
9306                    -20
9307                ],
9308                textStyle: {
9309                    color: 'auto',
9310                    fontSize: 20
9311                }
9312            },
9313            detail: {
9314                offsetCenter: [
9315                    0,
9316                    0
9317                ],
9318                textStyle: {
9319                    color: 'auto',
9320                    fontSize: 40
9321                }
9322            }
9323        },
9324        textStyle: { fontFamily: '微软雅黑, Arial, Verdana, sans-serif' }
9325    };
9326    return theme;
9327});define('zrender/dep/excanvas', ['require'], function (require) {
9328    if (!document.createElement('canvas').getContext) {
9329        (function () {
9330            var m = Math;
9331            var mr = m.round;
9332            var ms = m.sin;
9333            var mc = m.cos;
9334            var abs = m.abs;
9335            var sqrt = m.sqrt;
9336            var Z = 10;
9337            var Z2 = Z / 2;
9338            var IE_VERSION = +navigator.userAgent.match(/MSIE ([\d.]+)?/)[1];
9339            function getContext() {
9340                return this.context_ || (this.context_ = new CanvasRenderingContext2D_(this));
9341            }
9342            var slice = Array.prototype.slice;
9343            function bind(f, obj, var_args) {
9344                var a = slice.call(arguments, 2);
9345                return function () {
9346                    return f.apply(obj, a.concat(slice.call(arguments)));
9347                };
9348            }
9349            function encodeHtmlAttribute(s) {
9350                return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
9351            }
9352            function addNamespace(doc, prefix, urn) {
9353                if (!doc.namespaces[prefix]) {
9354                    doc.namespaces.add(prefix, urn, '#default#VML');
9355                }
9356            }
9357            function addNamespacesAndStylesheet(doc) {
9358                addNamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml');
9359                addNamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office');
9360                if (!doc.styleSheets['ex_canvas_']) {
9361                    var ss = doc.createStyleSheet();
9362                    ss.owningElement.id = 'ex_canvas_';
9363                    ss.cssText = 'canvas{display:inline-block;overflow:hidden;' + 'text-align:left;width:300px;height:150px}';
9364                }
9365            }
9366            addNamespacesAndStylesheet(document);
9367            var G_vmlCanvasManager_ = {
9368                init: function (opt_doc) {
9369                    var doc = opt_doc || document;
9370                    doc.createElement('canvas');
9371                    doc.attachEvent('onreadystatechange', bind(this.init_, this, doc));
9372                },
9373                init_: function (doc) {
9374                    var els = doc.getElementsByTagName('canvas');
9375                    for (var i = 0; i < els.length; i++) {
9376                        this.initElement(els[i]);
9377                    }
9378                },
9379                initElement: function (el) {
9380                    if (!el.getContext) {
9381                        el.getContext = getContext;
9382                        addNamespacesAndStylesheet(el.ownerDocument);
9383                        el.innerHTML = '';
9384                        el.attachEvent('onpropertychange', onPropertyChange);
9385                        el.attachEvent('onresize', onResize);
9386                        var attrs = el.attributes;
9387                        if (attrs.width && attrs.width.specified) {
9388                            el.style.width = attrs.width.nodeValue + 'px';
9389                        } else {
9390                            el.width = el.clientWidth;
9391                        }
9392                        if (attrs.height && attrs.height.specified) {
9393                            el.style.height = attrs.height.nodeValue + 'px';
9394                        } else {
9395                            el.height = el.clientHeight;
9396                        }
9397                    }
9398                    return el;
9399                }
9400            };
9401            function onPropertyChange(e) {
9402                var el = e.srcElement;
9403                switch (e.propertyName) {
9404                case 'width':
9405                    el.getContext().clearRect();
9406                    el.style.width = el.attributes.width.nodeValue + 'px';
9407                    el.firstChild.style.width = el.clientWidth + 'px';
9408                    break;
9409                case 'height':
9410                    el.getContext().clearRect();
9411                    el.style.height = el.attributes.height.nodeValue + 'px';
9412                    el.firstChild.style.height = el.clientHeight + 'px';
9413                    break;
9414                }
9415            }
9416            function onResize(e) {
9417                var el = e.srcElement;
9418                if (el.firstChild) {
9419                    el.firstChild.style.width = el.clientWidth + 'px';
9420                    el.firstChild.style.height = el.clientHeight + 'px';
9421                }
9422            }
9423            G_vmlCanvasManager_.init();
9424            var decToHex = [];
9425            for (var i = 0; i < 16; i++) {
9426                for (var j = 0; j < 16; j++) {
9427                    decToHex[i * 16 + j] = i.toString(16) + j.toString(16);
9428                }
9429            }
9430            function createMatrixIdentity() {
9431                return [
9432                    [
9433                        1,
9434                        0,
9435                        0
9436                    ],
9437                    [
9438                        0,
9439                        1,
9440                        0
9441                    ],
9442                    [
9443                        0,
9444                        0,
9445                        1
9446                    ]
9447                ];
9448            }
9449            function matrixMultiply(m1, m2) {
9450                var result = createMatrixIdentity();
9451                for (var x = 0; x < 3; x++) {
9452                    for (var y = 0; y < 3; y++) {
9453                        var sum = 0;
9454                        for (var z = 0; z < 3; z++) {
9455                            sum += m1[x][z] * m2[z][y];
9456                        }
9457                        result[x][y] = sum;
9458                    }
9459                }
9460                return result;
9461            }
9462            function copyState(o1, o2) {
9463                o2.fillStyle = o1.fillStyle;
9464                o2.lineCap = o1.lineCap;
9465                o2.lineJoin = o1.lineJoin;
9466                o2.lineWidth = o1.lineWidth;
9467                o2.miterLimit = o1.miterLimit;
9468                o2.shadowBlur = o1.shadowBlur;
9469                o2.shadowColor = o1.shadowColor;
9470                o2.shadowOffsetX = o1.shadowOffsetX;
9471                o2.shadowOffsetY = o1.shadowOffsetY;
9472                o2.strokeStyle = o1.strokeStyle;
9473                o2.globalAlpha = o1.globalAlpha;
9474                o2.font = o1.font;
9475                o2.textAlign = o1.textAlign;
9476                o2.textBaseline = o1.textBaseline;
9477                o2.scaleX_ = o1.scaleX_;
9478                o2.scaleY_ = o1.scaleY_;
9479                o2.lineScale_ = o1.lineScale_;
9480            }
9481            var colorData = {
9482                aliceblue: '#F0F8FF',
9483                antiquewhite: '#FAEBD7',
9484                aquamarine: '#7FFFD4',
9485                azure: '#F0FFFF',
9486                beige: '#F5F5DC',
9487                bisque: '#FFE4C4',
9488                black: '#000000',
9489                blanchedalmond: '#FFEBCD',
9490                blueviolet: '#8A2BE2',
9491                brown: '#A52A2A',
9492                burlywood: '#DEB887',
9493                cadetblue: '#5F9EA0',
9494                chartreuse: '#7FFF00',
9495                chocolate: '#D2691E',
9496                coral: '#FF7F50',
9497                cornflowerblue: '#6495ED',
9498                cornsilk: '#FFF8DC',
9499                crimson: '#DC143C',
9500                cyan: '#00FFFF',
9501                darkblue: '#00008B',
9502                darkcyan: '#008B8B',
9503                darkgoldenrod: '#B8860B',
9504                darkgray: '#A9A9A9',
9505                darkgreen: '#006400',
9506                darkgrey: '#A9A9A9',
9507                darkkhaki: '#BDB76B',
9508                darkmagenta: '#8B008B',
9509                darkolivegreen: '#556B2F',
9510                darkorange: '#FF8C00',
9511                darkorchid: '#9932CC',
9512                darkred: '#8B0000',
9513                darksalmon: '#E9967A',
9514                darkseagreen: '#8FBC8F',
9515                darkslateblue: '#483D8B',
9516                darkslategray: '#2F4F4F',
9517                darkslategrey: '#2F4F4F',
9518                darkturquoise: '#00CED1',
9519                darkviolet: '#9400D3',
9520                deeppink: '#FF1493',
9521                deepskyblue: '#00BFFF',
9522                dimgray: '#696969',
9523                dimgrey: '#696969',
9524                dodgerblue: '#1E90FF',
9525                firebrick: '#B22222',
9526                floralwhite: '#FFFAF0',
9527                forestgreen: '#228B22',
9528                gainsboro: '#DCDCDC',
9529                ghostwhite: '#F8F8FF',
9530                gold: '#FFD700',
9531                goldenrod: '#DAA520',
9532                grey: '#808080',
9533                greenyellow: '#ADFF2F',
9534                honeydew: '#F0FFF0',
9535                hotpink: '#FF69B4',
9536                indianred: '#CD5C5C',
9537                indigo: '#4B0082',
9538                ivory: '#FFFFF0',
9539                khaki: '#F0E68C',
9540                lavender: '#E6E6FA',
9541                lavenderblush: '#FFF0F5',
9542                lawngreen: '#7CFC00',
9543                lemonchiffon: '#FFFACD',
9544                lightblue: '#ADD8E6',
9545                lightcoral: '#F08080',
9546                lightcyan: '#E0FFFF',
9547                lightgoldenrodyellow: '#FAFAD2',
9548                lightgreen: '#90EE90',
9549                lightgrey: '#D3D3D3',
9550                lightpink: '#FFB6C1',
9551                lightsalmon: '#FFA07A',
9552                lightseagreen: '#20B2AA',
9553                lightskyblue: '#87CEFA',
9554                lightslategray: '#778899',
9555                lightslategrey: '#778899',
9556                lightsteelblue: '#B0C4DE',
9557                lightyellow: '#FFFFE0',
9558                limegreen: '#32CD32',
9559                linen: '#FAF0E6',
9560                magenta: '#FF00FF',
9561                mediumaquamarine: '#66CDAA',
9562                mediumblue: '#0000CD',
9563                mediumorchid: '#BA55D3',
9564                mediumpurple: '#9370DB',
9565                mediumseagreen: '#3CB371',
9566                mediumslateblue: '#7B68EE',
9567                mediumspringgreen: '#00FA9A',
9568                mediumturquoise: '#48D1CC',
9569                mediumvioletred: '#C71585',
9570                midnightblue: '#191970',
9571                mintcream: '#F5FFFA',
9572                mistyrose: '#FFE4E1',
9573                moccasin: '#FFE4B5',
9574                navajowhite: '#FFDEAD',
9575                oldlace: '#FDF5E6',
9576                olivedrab: '#6B8E23',
9577                orange: '#FFA500',
9578                orangered: '#FF4500',
9579                orchid: '#DA70D6',
9580                palegoldenrod: '#EEE8AA',
9581                palegreen: '#98FB98',
9582                paleturquoise: '#AFEEEE',
9583                palevioletred: '#DB7093',
9584                papayawhip: '#FFEFD5',
9585                peachpuff: '#FFDAB9',
9586                peru: '#CD853F',
9587                pink: '#FFC0CB',
9588                plum: '#DDA0DD',
9589                powderblue: '#B0E0E6',
9590                rosybrown: '#BC8F8F',
9591                royalblue: '#4169E1',
9592                saddlebrown: '#8B4513',
9593                salmon: '#FA8072',
9594                sandybrown: '#F4A460',
9595                seagreen: '#2E8B57',
9596                seashell: '#FFF5EE',
9597                sienna: '#A0522D',
9598                skyblue: '#87CEEB',
9599                slateblue: '#6A5ACD',
9600                slategray: '#708090',
9601                slategrey: '#708090',
9602                snow: '#FFFAFA',
vendor: 4,247 bytes, lines 9602-9709
9602
9603                springgreen: '#00FF7F',
9604                steelblue: '#4682B4',
9605                tan: '#D2B48C',
9606                thistle: '#D8BFD8',
9607                tomato: '#FF6347',
9608                turquoise: '#40E0D0',
9609                violet: '#EE82EE',
9610                wheat: '#F5DEB3',
9611                whitesmoke: '#F5F5F5',
9612                yellowgreen: '#9ACD32'
9613            };
9614            function getRgbHslContent(styleString) {
9615                var start = styleString.indexOf('(', 3);
9616                var end = styleString.indexOf(')', start + 1);
9617                var parts = styleString.substring(start + 1, end).split(',');
9618                if (parts.length != 4 || styleString.charAt(3) != 'a') {
9619                    parts[3] = 1;
9620                }
9621                return parts;
9622            }
9623            function percent(s) {
9624                return parseFloat(s) / 100;
9625            }
9626            function clamp(v, min, max) {
9627                return Math.min(max, Math.max(min, v));
9628            }
9629            function hslToRgb(parts) {
9630                var r, g, b, h, s, l;
9631                h = parseFloat(parts[0]) / 360 % 360;
9632                if (h < 0)
9633                    h++;
9634                s = clamp(percent(parts[1]), 0, 1);
9635                l = clamp(percent(parts[2]), 0, 1);
9636                if (s == 0) {
9637                    r = g = b = l;
9638                } else {
9639                    var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
9640                    var p = 2 * l - q;
9641                    r = hueToRgb(p, q, h + 1 / 3);
9642                    g = hueToRgb(p, q, h);
9643                    b = hueToRgb(p, q, h - 1 / 3);
9644                }
9645                return '#' + decToHex[Math.floor(r * 255)] + decToHex[Math.floor(g * 255)] + decToHex[Math.floor(b * 255)];
9646            }
9647            function hueToRgb(m1, m2, h) {
9648                if (h < 0)
9649                    h++;
9650                if (h > 1)
9651                    h--;
9652                if (6 * h < 1)
9653                    return m1 + (m2 - m1) * 6 * h;
9654                else if (2 * h < 1)
9655                    return m2;
9656                else if (3 * h < 2)
9657                    return m1 + (m2 - m1) * (2 / 3 - h) * 6;
9658                else
9659                    return m1;
9660            }
9661            var processStyleCache = {};
9662            function processStyle(styleString) {
9663                if (styleString in processStyleCache) {
9664                    return processStyleCache[styleString];
9665                }
9666                var str, alpha = 1;
9667                styleString = String(styleString);
9668                if (styleString.charAt(0) == '#') {
9669                    str = styleString;
9670                } else if (/^rgb/.test(styleString)) {
9671                    var parts = getRgbHslContent(styleString);
9672                    var str = '#', n;
9673                    for (var i = 0; i < 3; i++) {
9674                        if (parts[i].indexOf('%') != -1) {
9675                            n = Math.floor(percent(parts[i]) * 255);
9676                        } else {
9677                            n = +parts[i];
9678                        }
9679                        str += decToHex[clamp(n, 0, 255)];
9680                    }
9681                    alpha = +parts[3];
9682                } else if (/^hsl/.test(styleString)) {
9683                    var parts = getRgbHslContent(styleString);
9684                    str = hslToRgb(parts);
9685                    alpha = parts[3];
9686                } else {
9687                    str = colorData[styleString] || styleString;
9688                }
9689                return processStyleCache[styleString] = {
9690                    color: str,
9691                    alpha: alpha
9692                };
9693            }
9694            var DEFAULT_STYLE = {
9695                style: 'normal',
9696                variant: 'normal',
9697                weight: 'normal',
9698                size: 12,
9699                family: '微软雅黑'
9700            };
9701            var fontStyleCache = {};
9702            function processFontStyle(styleString) {
9703                if (fontStyleCache[styleString]) {
9704                    return fontStyleCache[styleString];
9705                }
9706                var el = document.createElement('div');
9707                var style = el.style;
9708                var fontFamily;
9709                try {
9710                    style.font = styleString;
9711                    fontFamily = style.fontFamily.split(',')[0];
9712                } catch (ex) {
9713                }
9714                return fontStyleCache[styleString] = {
9715                    style: style.fontStyle || DEFAULT_STYLE.style,
9716                    variant: style.fontVariant || DEFAULT_STYLE.variant,
9717                    weight: style.fontWeight || DEFAULT_STYLE.weight,
9718                    size: style.fontSize || DEFAULT_STYLE.size,
9719                    family: fontFamily || DEFAULT_STYLE.family
9720                };
9721            }
9722            function getComputedStyle(style, element) {
9723                var computedStyle = {};
9724                for (var p in style) {
9725                    computedStyle[p] = style[p];
9726                }
9727                var canvasFontSize = parseFloat(element.currentStyle.fontSize), fontSize = parseFloat(style.size);
9728                if (typeof style.size == 'number') {
9729                    computedStyle.size = style.size;
9730                } else if (style.size.indexOf('px') != -1) {
9731                    computedStyle.size = fontSize;
9732                } else if (style.size.indexOf('em') != -1) {
9733                    computedStyle.size = canvasFontSize * fontSize;
9734                } else if (style.size.indexOf('%') != -1) {
9735                    computedStyle.size = canvasFontSize / 100 * fontSize;
9736                } else if (style.size.indexOf('pt') != -1) {
9737                    computedStyle.size = fontSize / 0.75;
9738                } else {
9739                    computedStyle.size = canvasFontSize;
9740                }
9741                return computedStyle;
9742            }
9743            function buildStyle(style) {
9744                return style.style + ' ' + style.variant + ' ' + style.weight + ' ' + style.size + 'px \'' + style.family + '\'';
9745            }
9746            var lineCapMap = {
9747                'butt': 'flat',
9748                'round': 'round'
9749            };
9750            function processLineCap(lineCap) {
9751                return lineCapMap[lineCap] || 'square';
9752            }
9753            function CanvasRenderingContext2D_(canvasElement) {
9754                this.m_ = createMatrixIdentity();
9755                this.mStack_ = [];
9756                this.aStack_ = [];
9757                this.currentPath_ = [];
9758                this.strokeStyle = '#000';
9759                this.fillStyle = '#000';
9760                this.lineWidth = 1;
9761                this.lineJoin = 'miter';
9762                this.lineCap = 'butt';
9763                this.miterLimit = Z * 1;
9764                this.globalAlpha = 1;
9765                this.font = '12px 微软雅黑';
9766                this.textAlign = 'left';
9767                this.textBaseline = 'alphabetic';
9768                this.canvas = canvasElement;
9769                var cssText = 'width:' + canvasElement.clientWidth + 'px;height:' + canvasElement.clientHeight + 'px;overflow:hidden;position:absolute';
9770                var el = canvasElement.ownerDocument.createElement('div');
9771                el.style.cssText = cssText;
9772                canvasElement.appendChild(el);
9773                var overlayEl = el.cloneNode(false);
9774                overlayEl.style.backgroundColor = '#fff';
9775                overlayEl.style.filter = 'alpha(opacity=0)';
9776                canvasElement.appendChild(overlayEl);
9777                this.element_ = el;
9778                this.scaleX_ = 1;
9779                this.scaleY_ = 1;
9780                this.lineScale_ = 1;
9781            }
9782            var contextPrototype = CanvasRenderingContext2D_.prototype;
9783            contextPrototype.clearRect = function () {
9784                if (this.textMeasureEl_) {
9785                    this.textMeasureEl_.removeNode(true);
9786                    this.textMeasureEl_ = null;
9787                }
9788                this.element_.innerHTML = '';
9789            };
9790            contextPrototype.beginPath = function () {
9791                this.currentPath_ = [];
9792            };
9793            contextPrototype.moveTo = function (aX, aY) {
9794                var p = getCoords(this, aX, aY);
9795                this.currentPath_.push({
9796                    type: 'moveTo',
9797                    x: p.x,
9798                    y: p.y
9799                });
9800                this.currentX_ = p.x;
9801                this.currentY_ = p.y;
9802            };
9803            contextPrototype.lineTo = function (aX, aY) {
9804                var p = getCoords(this, aX, aY);
9805                this.currentPath_.push({
9806                    type: 'lineTo',
9807                    x: p.x,
9808                    y: p.y
9809                });
9810                this.currentX_ = p.x;
9811                this.currentY_ = p.y;
9812            };
9813            contextPrototype.bezierCurveTo = function (aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
9814                var p = getCoords(this, aX, aY);
9815                var cp1 = getCoords(this, aCP1x, aCP1y);
9816                var cp2 = getCoords(this, aCP2x, aCP2y);
9817                bezierCurveTo(this, cp1, cp2, p);
9818            };
9819            function bezierCurveTo(self, cp1, cp2, p) {
9820                self.currentPath_.push({
9821                    type: 'bezierCurveTo',
9822                    cp1x: cp1.x,
vendor: 7,149 bytes, lines 9823-9977
9823                    cp1y: cp1.y,
9824                    cp2x: cp2.x,
9825                    cp2y: cp2.y,
9826                    x: p.x,
9827                    y: p.y
9828                });
9829                self.currentX_ = p.x;
9830                self.currentY_ = p.y;
9831            }
9832            contextPrototype.quadraticCurveTo = function (aCPx, aCPy, aX, aY) {
9833                var cp = getCoords(this, aCPx, aCPy);
9834                var p = getCoords(this, aX, aY);
9835                var cp1 = {
9836                    x: this.currentX_ + 2 / 3 * (cp.x - this.currentX_),
9837                    y: this.currentY_ + 2 / 3 * (cp.y - this.currentY_)
9838                };
9839                var cp2 = {
9840                    x: cp1.x + (p.x - this.currentX_) / 3,
9841                    y: cp1.y + (p.y - this.currentY_) / 3
9842                };
9843                bezierCurveTo(this, cp1, cp2, p);
9844            };
9845            contextPrototype.arc = function (aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
9846                aRadius *= Z;
9847                var arcType = aClockwise ? 'at' : 'wa';
9848                var xStart = aX + mc(aStartAngle) * aRadius - Z2;
9849                var yStart = aY + ms(aStartAngle) * aRadius - Z2;
9850                var xEnd = aX + mc(aEndAngle) * aRadius - Z2;
9851                var yEnd = aY + ms(aEndAngle) * aRadius - Z2;
9852                if (xStart == xEnd && !aClockwise) {
9853                    xStart += 0.125;
9854                }
9855                var p = getCoords(this, aX, aY);
9856                var pStart = getCoords(this, xStart, yStart);
9857                var pEnd = getCoords(this, xEnd, yEnd);
9858                this.currentPath_.push({
9859                    type: arcType,
9860                    x: p.x,
9861                    y: p.y,
9862                    radius: aRadius,
9863                    xStart: pStart.x,
9864                    yStart: pStart.y,
9865                    xEnd: pEnd.x,
9866                    yEnd: pEnd.y
9867                });
9868            };
9869            contextPrototype.rect = function (aX, aY, aWidth, aHeight) {
9870                this.moveTo(aX, aY);
9871                this.lineTo(aX + aWidth, aY);
9872                this.lineTo(aX + aWidth, aY + aHeight);
9873                this.lineTo(aX, aY + aHeight);
9874                this.closePath();
9875            };
9876            contextPrototype.strokeRect = function (aX, aY, aWidth, aHeight) {
9877                var oldPath = this.currentPath_;
9878                this.beginPath();
9879                this.moveTo(aX, aY);
9880                this.lineTo(aX + aWidth, aY);
9881                this.lineTo(aX + aWidth, aY + aHeight);
9882                this.lineTo(aX, aY + aHeight);
9883                this.closePath();
9884                this.stroke();
9885                this.currentPath_ = oldPath;
9886            };
9887            contextPrototype.fillRect = function (aX, aY, aWidth, aHeight) {
9888                var oldPath = this.currentPath_;
9889                this.beginPath();
9890                this.moveTo(aX, aY);
9891                this.lineTo(aX + aWidth, aY);
9892                this.lineTo(aX + aWidth, aY + aHeight);
9893                this.lineTo(aX, aY + aHeight);
9894                this.closePath();
9895                this.fill();
9896                this.currentPath_ = oldPath;
9897            };
9898            contextPrototype.createLinearGradient = function (aX0, aY0, aX1, aY1) {
9899                var gradient = new CanvasGradient_('gradient');
9900                gradient.x0_ = aX0;
9901                gradient.y0_ = aY0;
9902                gradient.x1_ = aX1;
9903                gradient.y1_ = aY1;
9904                return gradient;
9905            };
9906            contextPrototype.createRadialGradient = function (aX0, aY0, aR0, aX1, aY1, aR1) {
9907                var gradient = new CanvasGradient_('gradientradial');
9908                gradient.x0_ = aX0;
9909                gradient.y0_ = aY0;
9910                gradient.r0_ = aR0;
9911                gradient.x1_ = aX1;
9912                gradient.y1_ = aY1;
9913                gradient.r1_ = aR1;
9914                return gradient;
9915            };
9916            contextPrototype.drawImage = function (image, var_args) {
9917                var dx, dy, dw, dh, sx, sy, sw, sh;
9918                var oldRuntimeWidth = image.runtimeStyle.width;
9919                var oldRuntimeHeight = image.runtimeStyle.height;
9920                image.runtimeStyle.width = 'auto';
9921                image.runtimeStyle.height = 'auto';
9922                var w = image.width;
9923                var h = image.height;
9924                image.runtimeStyle.width = oldRuntimeWidth;
9925                image.runtimeStyle.height = oldRuntimeHeight;
9926                if (arguments.length == 3) {
9927                    dx = arguments[1];
9928                    dy = arguments[2];
9929                    sx = sy = 0;
9930                    sw = dw = w;
9931                    sh = dh = h;
9932                } else if (arguments.length == 5) {
9933                    dx = arguments[1];
9934                    dy = arguments[2];
9935                    dw = arguments[3];
9936                    dh = arguments[4];
9937                    sx = sy = 0;
9938                    sw = w;
9939                    sh = h;
9940                } else if (arguments.length == 9) {
9941                    sx = arguments[1];
9942                    sy = arguments[2];
9943                    sw = arguments[3];
9944                    sh = arguments[4];
9945                    dx = arguments[5];
9946                    dy = arguments[6];
9947                    dw = arguments[7];
9948                    dh = arguments[8];
9949                } else {
9950                    throw Error('Invalid number of arguments');
9951                }
9952                var d = getCoords(this, dx, dy);
9953                var w2 = sw / 2;
9954                var h2 = sh / 2;
9955                var vmlStr = [];
9956                var W = 10;
9957                var H = 10;
9958                var scaleX = scaleY = 1;
9959                vmlStr.push(' <g_vml_:group', ' coordsize="', Z * W, ',', Z * H, '"', ' coordorigin="0,0"', ' style="width:', W, 'px;height:', H, 'px;position:absolute;');
9960                if (this.m_[0][0] != 1 || this.m_[0][1] || this.m_[1][1] != 1 || this.m_[1][0]) {
9961                    var filter = [];
9962                    var scaleX = this.scaleX_;
9963                    var scaleY = this.scaleY_;
9964                    filter.push('M11=', this.m_[0][0] / scaleX, ',', 'M12=', this.m_[1][0] / scaleY, ',', 'M21=', this.m_[0][1] / scaleX, ',', 'M22=', this.m_[1][1] / scaleY, ',', 'Dx=', mr(d.x / Z), ',', 'Dy=', mr(d.y / Z), '');
9965                    var max = d;
9966                    var c2 = getCoords(this, dx + dw, dy);
9967                    var c3 = getCoords(this, dx, dy + dh);
9968                    var c4 = getCoords(this, dx + dw, dy + dh);
9969                    max.x = m.max(max.x, c2.x, c3.x, c4.x);
9970                    max.y = m.max(max.y, c2.y, c3.y, c4.y);
9971                    vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z), 'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(', filter.join(''), ', SizingMethod=\'clip\');');
9972                } else {
9973                    vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;');
9974                }
9975                vmlStr.push(' ">');
9976                if (sx || sy) {
9977                    vmlStr.push('<div style="overflow: hidden;
9977 width:', Math.ceil((dw + sx * dw / sw) * scaleX), 'px;', ' height:', Math.ceil((dh + sy * dh / sh) * scaleY), 'px;', ' filter:progid:DxImageTransform.Microsoft.Matrix(Dx=', -sx * dw / sw * scaleX, ',Dy=', -sy * dh / sh * scaleY, ');">');
9978                }
9979                vmlStr.push('<div style="width:', Math.round(scaleX * w * dw / sw), 'px;', ' height:', Math.round(scaleY * h * dh / sh), 'px;', ' filter:');
9980                if (this.globalAlpha < 1) {
9981                    vmlStr.push(' progid:DXImageTransform.Microsoft.Alpha(opacity=' + this.globalAlpha * 100 + ')');
9982                }
9983                vmlStr.push(' progid:DXImageTransform.Microsoft.AlphaImageLoader(src=', image.src, ',sizingMethod=scale)">');
9984                if (sx || sy)
9985                    vmlStr.push('</div>');
9986                vmlStr.push('</div></div>');
9987                this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join(''));
9988            };
9989            contextPrototype.stroke = function (aFill) {
9990                var lineStr = [];
9991                var lineOpen = false;
9992                var W = 10;
9993                var H = 10;
9994                lineStr.push('<g_vml_:shape', ' filled="', !!aFill, '"', ' style="position:absolute;width:', W, 'px;height:', H, 'px;"', ' coordorigin="0,0"', ' coordsize="', Z * W, ',', Z * H, '"', ' stroked="', !aFill, '"', ' path="');
9995                var newSeq = false;
9996                var min = {
9997                    x: null,
9998                    y: null
9999                };
10000                var max = {
10001                    x: null,
10002                    y: null
10003                };
10004                for (var i = 0; i < this.currentPath_.length; i++) {
10005                    var p = this.currentPath_[i];
10006                    var c;
10007                    switch (p.type) {
10008                    case 'moveTo':
10009                        c = p;
10010                        lineStr.push(' m ', mr(p.x), ',', mr(p.y));
10011                        break;
10012                    case 'lineTo':
10013                        lineStr.push(' l ', mr(p.x), ',', mr(p.y));
10014                        break;
10015                    case 'close':
10016                        lineStr.push(' x ');
10017                        p = null;
10018                        break;
10019                    case 'bezierCurveTo':
10020                        lineStr.push(' c ', mr(p.cp1x), ',', mr(p.cp1y), ',', mr(p.cp2x), ',', mr(p.cp2y), ',', mr(p.x), ',', mr(p.y));
10021                        break;
10022                    case 'at':
10023                    case 'wa':
10024                        lineStr.push(' ', p.type, ' ', mr(p.x - this.scaleX_ * p.radius), ',', mr(p.y - this.scaleY_ * p.radius), ' ', mr(p.x + this.scaleX_ * p.radius), ',', mr(p.y + this.scaleY_ * p.radius), ' ', mr(p.xStart), ',', mr(p.yStart), ' ', mr(p.xEnd), ',', mr(p.yEnd));
10025                        break;
10026                    }
10027                    if (p) {
10028                        if (min.x == null || p.x < min.x) {
10029                            min.x = p.x;
10030                        }
10031                        if (max.x == null || p.x > max.x) {
10032                            max.x = p.x;
10033                        }
10034                        if (min.y == null || p.y < min.y) {
10035                            min.y = p.y;
10036                        }
10037                        if (max.y == null || p.y > max.y) {
10038                            max.y = p.y;
10039                        }
10040                    }
10041                }
10042                lineStr.push(' ">');
10043                if (!aFill) {
10044                    appendStroke(this, lineStr);
10045                } else {
10046                    appendFill(this, lineStr, min, max);
10047                }
10048                lineStr.push('</g_vml_:shape>');
10049                this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
10050            };
10051            function appendStroke(ctx, lineStr) {
10052                var a = processStyle(ctx.strokeStyle);
10053                var color = a.color;
10054                var opacity = a.alpha * ctx.globalAlpha;
10055                var lineWidth = ctx.lineScale_ * ctx.lineWidth;
10056                if (lineWidth < 1) {
10057                    opacity *= lineWidth;
10058                }
10059                lineStr.push('<g_vml_:stroke', ' opacity="', opacity, '"', ' joinstyle="', ctx.lineJoin, '"', ' miterlimit="', ctx.miterLimit, '"', ' endcap="', processLineCap(ctx.lineCap), '"', ' weight="', lineWidth, 'px"', ' color="', color, '" />');
10060            }
10061            function appendFill(ctx, lineStr, min, max) {
10062                var fillStyle = ctx.fillStyle;
10063                var arcScaleX = ctx.scaleX_;
10064                var arcScaleY = ctx.scaleY_;
10065                var width = max.x - min.x;
10066                var height = max.y - min.y;
10067                if (fillStyle instanceof CanvasGradient_) {
10068                    var angle = 0;
10069                    var focus = {
10070                        x: 0,
10071                        y: 0
10072                    };
10073                    var shift = 0;
10074                    var expansion = 1;
10075                    if (fillStyle.type_ == 'gradient') {
10076                        var x0 = fillStyle.x0_ / arcScaleX;
10077                        var y0 = fillStyle.y0_ / arcScaleY;
10078                        var x1 = fillStyle.x1_ / arcScaleX;
10079                        var y1 = fillStyle.y1_ / arcScaleY;
10080                        var p0 = getCoords(ctx, x0, y0);
10081                        var p1 = getCoords(ctx, x1, y1);
10082                        var dx = p1.x - p0.x;
10083                        var dy = p1.y - p0.y;
10084                        angle = Math.atan2(dx, dy) * 180 / Math.PI;
10085                        if (angle < 0) {
vendor: 12,243 bytes, lines 10086-10379
10086                            angle += 360;
10087                        }
10088                        if (angle < 0.000001) {
10089                            angle = 0;
10090                        }
10091                    } else {
10092                        var p0 = getCoords(ctx, fillStyle.x0_, fillStyle.y0_);
10093                        focus = {
10094                            x: (p0.x - min.x) / width,
10095                            y: (p0.y - min.y) / height
10096                        };
10097                        width /= arcScaleX * Z;
10098                        height /= arcScaleY * Z;
10099                        var dimension = m.max(width, height);
10100                        shift = 2 * fillStyle.r0_ / dimension;
10101                        expansion = 2 * fillStyle.r1_ / dimension - shift;
10102                    }
10103                    var stops = fillStyle.colors_;
10104                    stops.sort(function (cs1, cs2) {
10105                        return cs1.offset - cs2.offset;
10106                    });
10107                    var length = stops.length;
10108                    var color1 = stops[0].color;
10109                    var color2 = stops[length - 1].color;
10110                    var opacity1 = stops[0].alpha * ctx.globalAlpha;
10111                    var opacity2 = stops[length - 1].alpha * ctx.globalAlpha;
10112                    var colors = [];
10113                    for (var i = 0; i < length; i++) {
10114                        var stop = stops[i];
10115                        colors.push(stop.offset * expansion + shift + ' ' + stop.color);
10116                    }
10117                    lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"', ' method="none" focus="100%"', ' color="', color1, '"', ' color2="', color2, '"', ' colors="', colors.join(','), '"', ' opacity="', opacity2, '"', ' g_o_:opacity2="', opacity1, '"', ' angle="', angle, '"', ' focusposition="', focus.x, ',', focus.y, '" />');
10118                } else if (fillStyle instanceof CanvasPattern_) {
10119                    if (width && height) {
10120                        var deltaLeft = -min.x;
10121                        var deltaTop = -min.y;
10122                        lineStr.push('<g_vml_:fill', ' position="', deltaLeft / width * arcScaleX * arcScaleX, ',', deltaTop / height * arcScaleY * arcScaleY, '"', ' type="tile"', ' src="', fillStyle.src_, '" />');
10123                    }
10124                } else {
10125                    var a = processStyle(ctx.fillStyle);
10126                    var color = a.color;
10127                    var opacity = a.alpha * ctx.globalAlpha;
10128                    lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity, '" />');
10129                }
10130            }
10131            contextPrototype.fill = function () {
10132                this.stroke(true);
10133            };
10134            contextPrototype.closePath = function () {
10135                this.currentPath_.push({ type: 'close' });
10136            };
10137            function getCoords(ctx, aX, aY) {
10138                var m = ctx.m_;
10139                return {
10140                    x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2,
10141                    y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2
10142                };
10143            }
10144            ;
10145            contextPrototype.save = function () {
10146                var o = {};
10147                copyState(this, o);
10148                this.aStack_.push(o);
10149                this.mStack_.push(this.m_);
10150                this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
10151            };
10152            contextPrototype.restore = function () {
10153                if (this.aStack_.length) {
10154                    copyState(this.aStack_.pop(), this);
10155                    this.m_ = this.mStack_.pop();
10156                }
10157            };
10158            function matrixIsFinite(m) {
10159                return isFinite(m[0][0]) && isFinite(m[0][1]) && isFinite(m[1][0]) && isFinite(m[1][1]) && isFinite(m[2][0]) && isFinite(m[2][1]);
10160            }
10161            function setM(ctx, m, updateLineScale) {
10162                if (!matrixIsFinite(m)) {
10163                    return;
10164                }
10165                ctx.m_ = m;
10166                ctx.scaleX_ = Math.sqrt(m[0][0] * m[0][0] + m[0][1] * m[0][1]);
10167                ctx.scaleY_ = Math.sqrt(m[1][0] * m[1][0] + m[1][1] * m[1][1]);
10168                if (updateLineScale) {
10169                    var det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
10170                    ctx.lineScale_ = sqrt(abs(det));
10171                }
10172            }
10173            contextPrototype.translate = function (aX, aY) {
10174                var m1 = [
10175                    [
10176                        1,
10177                        0,
10178                        0
10179                    ],
10180                    [
10181                        0,
10182                        1,
10183                        0
10184                    ],
10185                    [
10186                        aX,
10187                        aY,
10188                        1
10189                    ]
10190                ];
10191                setM(this, matrixMultiply(m1, this.m_), false);
10192            };
10193            contextPrototype.rotate = function (aRot) {
10194                var c = mc(aRot);
10195                var s = ms(aRot);
10196                var m1 = [
10197                    [
10198                        c,
10199                        s,
10200                        0
10201                    ],
10202                    [
10203                        -s,
10204                        c,
10205                        0
10206                    ],
10207                    [
10208                        0,
10209                        0,
10210                        1
10211                    ]
10212                ];
10213                setM(this, matrixMultiply(m1, this.m_), false);
10214            };
10215            contextPrototype.scale = function (aX, aY) {
10216                var m1 = [
10217                    [
10218                        aX,
10219                        0,
10220                        0
10221                    ],
10222                    [
10223                        0,
10224                        aY,
10225                        0
10226                    ],
10227                    [
10228                        0,
10229                        0,
10230                        1
10231                    ]
10232                ];
10233                setM(this, matrixMultiply(m1, this.m_), true);
10234            };
10235            contextPrototype.transform = function (m11, m12, m21, m22, dx, dy) {
10236                var m1 = [
10237                    [
10238                        m11,
10239                        m12,
10240                        0
10241                    ],
10242                    [
10243                        m21,
10244                        m22,
10245                        0
10246                    ],
10247                    [
10248                        dx,
10249                        dy,
10250                        1
10251                    ]
10252                ];
10253                setM(this, matrixMultiply(m1, this.m_), true);
10254            };
10255            contextPrototype.setTransform = function (m11, m12, m21, m22, dx, dy) {
10256                var m = [
10257                    [
10258                        m11,
10259                        m12,
10260                        0
10261                    ],
10262                    [
10263                        m21,
10264                        m22,
10265                        0
10266                    ],
10267                    [
10268                        dx,
10269                        dy,
10270                        1
10271                    ]
10272                ];
10273                setM(this, m, true);
10274            };
10275            contextPrototype.drawText_ = function (text, x, y, maxWidth, stroke) {
10276                var m = this.m_, delta = 1000, left = 0, right = delta, offset = {
10277                        x: 0,
10278                        y: 0
10279                    }, lineStr = [];
10280                var fontStyle = getComputedStyle(processFontStyle(this.font), this.element_);
10281                var fontStyleString = buildStyle(fontStyle);
10282                var elementStyle = this.element_.currentStyle;
10283                var textAlign = this.textAlign.toLowerCase();
10284                switch (textAlign) {
10285                case 'left':
10286                case 'center':
10287                case 'right':
10288                    break;
10289                case 'end':
10290                    textAlign = elementStyle.direction == 'ltr' ? 'right' : 'left';
10291                    break;
10292                case 'start':
10293                    textAlign = elementStyle.direction == 'rtl' ? 'right' : 'left';
10294                    break;
10295                default:
10296                    textAlign = 'left';
10297                }
10298                switch (this.textBaseline) {
10299                case 'hanging':
10300                case 'top':
10301                    offset.y = fontStyle.size / 1.75;
10302                    break;
10303                case 'middle':
10304                    break;
10305                default:
10306                case null:
10307                case 'alphabetic':
10308                case 'ideographic':
10309                case 'bottom':
10310                    offset.y = -fontStyle.size / 2.25;
10311                    break;
10312                }
10313                switch (textAlign) {
10314                case 'right':
10315                    left = delta;
10316                    right = 0.05;
10317                    break;
10318                case 'center':
10319                    left = right = delta / 2;
10320                    break;
10321                }
10322                var d = getCoords(this, x + offset.x, y + offset.y);
10323                lineStr.push('<g_vml_:line from="', -left, ' 0" to="', right, ' 0.05" ', ' coordsize="100 100" coordorigin="0 0"', ' filled="', !stroke, '" stroked="', !!stroke, '" style="position:absolute;width:1px;height:1px;">');
10324                if (stroke) {
10325                    appendStroke(this, lineStr);
10326                } else {
10327                    appendFill(this, lineStr, {
10328                        x: -left,
10329                        y: 0
10330                    }, {
10331                        x: right,
10332                        y: fontStyle.size
10333                    });
10334                }
10335                var skewM = m[0][0].toFixed(3) + ',' + m[1][0].toFixed(3) + ',' + m[0][1].toFixed(3) + ',' + m[1][1].toFixed(3) + ',0,0';
10336                var skewOffset = mr(d.x / Z) + ',' + mr(d.y / Z);
10337                lineStr.push('<g_vml_:skew on="t" matrix="', skewM, '" ', ' offset="', skewOffset, '" origin="', left, ' 0" />', '<g_vml_:path textpathok="true" />', '<g_vml_:textpath on="true" string="', encodeHtmlAttribute(text), '" style="v-text-align:', textAlign, ';font:', encodeHtmlAttribute(fontStyleString), '" /></g_vml_:line>');
10338                this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
10339            };
10340            contextPrototype.fillText = function (text, x, y, maxWidth) {
10341                this.drawText_(text, x, y, maxWidth, false);
10342            };
10343            contextPrototype.strokeText = function (text, x, y, maxWidth) {
10344                this.drawText_(text, x, y, maxWidth, true);
10345            };
10346            contextPrototype.measureText = function (text) {
10347                if (!this.textMeasureEl_) {
10348                    var s = '<span style="position:absolute;' + 'top:-20000px;left:0;padding:0;margin:0;border:none;' + 'white-space:pre;"></span>';
10349                    this.element_.insertAdjacentHTML('beforeEnd', s);
10350                    this.textMeasureEl_ = this.element_.lastChild;
10351                }
10352                var doc = this.element_.ownerDocument;
10353                this.textMeasureEl_.innerHTML = '';
10354                try {
10355                    this.textMeasureEl_.style.font = this.font;
10356                } catch (ex) {
10357                }
10358                this.textMeasureEl_.appendChild(doc.createTextNode(text));
10359                return { width: this.textMeasureEl_.offsetWidth };
10360            };
10361            contextPrototype.clip = function () {
10362            };
10363            contextPrototype.arcTo = function () {
10364            };
10365            contextPrototype.createPattern = function (image, repetition) {
10366                return new CanvasPattern_(image, repetition);
10367            };
10368            function CanvasGradient_(aType) {
10369                this.type_ = aType;
10370                this.x0_ = 0;
10371                this.y0_ = 0;
10372                this.r0_ = 0;
10373                this.x1_ = 0;
10374                this.y1_ = 0;
10375                this.r1_ = 0;
10376                this.colors_ = [];
10377            }
10378            CanvasGradient_.prototype.addColorStop = function (aOffset, aColor) {
10379                aColor = processStyle(aColor);
10380                this.colors_.push({
10381                    offset: aOffset,
10382                    color: aColor.color,
10383                    alpha: aColor.alpha
10384                });
10385            };
10386            function CanvasPattern_(image, repetition) {
10387                assertImageIsValid(image);
10388                switch (repetition) {
10389                case 'repeat':
10390                case null:
10391                case '':
10392                    this.repetition_ = 'repeat';
10393                    break;
10394                case 'repeat-x':
10395                case 'repeat-y':
10396                case 'no-repeat':
10397                    this.repetition_ = repetition;
10398                    break;
10399                default:
10400                    throwException('SYNTAX_ERR');
10401                }
10402                this.src_ = image.src;
10403                this.width_ = image.width;
10404                this.height_ = image.height;
10405            }
10406            function throwException(s) {
10407                throw new DOMException_(s);
10408            }
10409            function assertImageIsValid(img) {
10410                if (!img || img.nodeType != 1 || img.tagName != 'IMG') {
10411                    throwException('TYPE_MISMATCH_ERR');
10412                }
10413                if (img.readyState != 'complete') {
10414                    throwException('INVALID_STATE_ERR');
10415                }
10416            }
10417            function DOMException_(s) {
10418                this.code = this[s];
10419                this.message = s + ': DOM Exception ' + this.code;
10420            }
10421            var p = DOMException_.prototype = new Error();
10422            p.INDEX_SIZE_ERR = 1;
10423            p.DOMSTRING_SIZE_ERR = 2;
10424            p.HIERARCHY_REQUEST_ERR = 3;
10425            p.WRONG_DOCUMENT_ERR = 4;
10426            p.INVALID_CHARACTER_ERR = 5;
10427            p.NO_DATA_ALLOWED_ERR = 6;
10428            p.NO_MODIFICATION_ALLOWED_ERR = 7;
10429            p.NOT_FOUND_ERR = 8;
10430            p.NOT_SUPPORTED_ERR = 9;
10431            p.INUSE_ATTRIBUTE_ERR = 10;
10432            p.INVALID_STATE_ERR = 11;
10433            p.SYNTAX_ERR = 12;
10434            p.INVALID_MODIFICATION_ERR = 13;
10435            p.NAMESPACE_ERR = 14;
10436            p.INVALID_ACCESS_ERR = 15;
10437            p.VALIDATION_ERR = 16;
10438            p.TYPE_MISMATCH_ERR = 17;
10439            G_vmlCanvasManager = G_vmlCanvasManager_;
10440            CanvasRenderingContext2D = CanvasRenderingContext2D_;
10441            CanvasGradient = CanvasGradient_;
10442            CanvasPattern = CanvasPattern_;
10443            DOMException = DOMException_;
10444        }());
10445    } else {
10446        G_vmlCanvasManager = false;
10447    }
10448    return G_vmlCanvasManager;
10449});define('zrender/mixin/Eventful', ['require'], function (require) {
10450    var Eventful = function () {
10451        this._handlers = {};
10452    };
10453    Eventful.prototype.one = function (event, handler, context) {
10454        var _h = this._handlers;
10455        if (!handler || !event) {
10456            return this;
10457        }
10458        if (!_h[event]) {
10459            _h[event] = [];
10460        }
10461        _h[event].push({
10462            h: handler,
10463            one: true,
10464            ctx: context || this
10465        });
10466        return this;
10467    };
10468    Eventful.prototype.bind = function (event, handler, context) {
10469        var _h = this._handlers;
10470        if (!handler || !event) {
10471            return this;
10472        }
10473        if (!_h[event]) {
10474            _h[event] = [];
10475        }
10476        _h[event].push({
10477            h: handler,
10478            one: false,
10479            ctx: context || this
10480        });
10481        return this;
10482    };
10483    Eventful.prototype.unbind = function (event, handler) {
10484        var _h = this._handlers;
10485        if (!event) {
10486            this._handlers = {};
10487            return this;
10488        }
10489        if (handler) {
10490            if (_h[event]) {
10491                var newList = [];
10492                for (var i = 0, l = _h[event].length; i < l; i++) {
10493                    if (_h[event][i]['h'] != handler) {
10494                        newList.push(_h[event][i]);
10495                    }
10496                }
10497                _h[event] = newList;
10498            }
10499            if (_h[event] && _h[event].length === 0) {
10500                delete _h[event];
10501            }
10502        } else {
10503            delete _h[event];
10504        }
10505        return this;
10506    };
10507    Eventful.prototype.dispatch = function (type) {
10508        if (this._handlers[type]) {
10509            var args = arguments;
10510            var argLen = args.length;
10511            if (argLen > 3) {
10512                args = Array.prototype.slice.call(args, 1);
10513            }
10514            var _h = this._handlers[type];
10515            var len = _h.length;
10516            for (var i = 0; i < len;) {
10517                switch (argLen) {
10518                case 1:
10519                    _h[i]['h'].call(_h[i]['ctx']);
10520                    break;
10521                case 2:
10522                    _h[i]['h'].call(_h[i]['ctx'], args[1]);
10523                    break;
10524                case 3:
10525                    _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
10526                    break;
10527                default:
10528                    _h[i]['h'].apply(_h[i]['ctx'], args);
10529                    break;
10530                }
10531                if (_h[i]['one']) {
10532                    _h.splice(i, 1);
10533                    len--;
10534                } else {
10535                    i++;
10536                }
10537            }
10538        }
10539        return this;
10540    };
10541    Eventful.prototype.dispatchWithContext = function (type) {
10542        if (this._handlers[type]) {
10543            var args = arguments;
10544            var argLen = args.length;
10545            if (argLen > 4) {
10546                args = Array.prototype.slice.call(args, 1, args.length - 1);
10547            }
10548            var ctx = args[args.length - 1];
10549            var _h = this._handlers[type];
10550            var len = _h.length;
10551            for (var i = 0; i < len;) {
10552                switch (argLen) {
10553                case 1:
10554                    _h[i]['h'].call(ctx);
10555                    break;
10556                case 2:
10557                    _h[i]['h'].call(ctx, args[1]);
10558                    break;
10559                case 3:
10560                    _h[i]['h'].call(ctx, args[1], args[2]);
10561                    break;
10562                default:
10563                    _h[i]['h'].apply(ctx, args);
10564                    break;
10565                }
10566                if (_h[i]['one']) {
10567                    _h.splice(i, 1);
10568                    len--;
10569                } else {
10570                    i++;
10571                }
10572            }
10573        }
10574        return this;
10575    };
10576    return Eventful;
10577});define('zrender/tool/log', [
10578    'require',
10579    '../config'
10580], function (require) {
10581    var config = require('../config');
10582    return function () {
10583        if (config.debugMode === 0) {
10584            return;
10585        } else if (config.debugMode == 1) {
10586            for (var k in arguments) {
10587                throw new Error(arguments[k]);
10588            }
10589        } else if (config.debugMode > 1) {
10590            for (var k in arguments) {
10591                console.log(arguments[k]);
10592            }
10593        }
10594    };
10595});define('zrender/tool/guid', [], function () {
10596    var idStart = 2311;
10597    return function () {
10598        return 'zrender__' + idStart++;
10599    };
10600});define('zrender/Handler', [
10601    'require',
10602    './config',
10603    './tool/env',
10604    './tool/event',
10605    './tool/util',
10606    './tool/vector',
10607    './tool/matrix',
10608    './mixin/Eventful'
10609], function (require) {
10610    'use strict';
10611    var config = require('./config');
10612    var env = require('./tool/env');
10613    var eventTool = require('./tool/event');
10614    var util = require('./tool/util');
10615    var vec2 = require('./tool/vector');
10616    var mat2d = require('./tool/matrix');
10617    var EVENT = config.EVENT;
10618    var Eventful = require('./mixin/Eventful');
10619    var domHandlerNames = [
10620        'resize',
10621        'click',
10622        'dblclick',
10623        'mousewheel',
10624        'mousemove',
10625        'mouseout',
10626        'mouseup',
10627        'mousedown',
10628        'touchstart',
10629        'touchend',
10630        'touchmove'
10631    ];
10632    var isZRenderElement = function (event) {
10633        if (window.G_vmlCanvasManager) {
10634            return true;
10635        }
10636        event = event || window.event;
10637        var target = event.toElement || event.relatedTarget || event.srcElement || event.target;
10638        return target && target.className.match(config.elementClassName);
10639    };
10640    var domHandlers = {
10641        resize: function (event) {
10642            event = event || window.event;
10643            this._lastHover = null;
10644            this._isMouseDown = 0;
10645            this.dispatch(EVENT.RESIZE, event);
10646        },
10647        click: function (event, manually) {
10648            if (!isZRenderElement(event) && !manually) {
10649                return;
10650            }
10651            event = this._zrenderEventFixed(event);
10652            var _lastHover = this._lastHover;
10653            if (_lastHover && _lastHover.clickable || !_lastHover) {
10654                if (this._clickThreshold < 5) {
10655                    this._dispatchAgency(_lastHover, EVENT.CLICK, event);
10656                }
10657            }
10658            this._mousemoveHandler(event);
10659        },
10660        dblclick: function (event, manually) {
10661            if (!isZRenderElement(event) && !manually) {
10662                return;
10663            }
10664            event = event || window.event;
10665            event = this._zrenderEventFixed(event);
10666            var _lastHover = this._lastHover;
10667            if (_lastHover && _lastHover.clickable || !_lastHover) {
10668                if (this._clickThreshold < 5) {
10669                    this._dispatchAgency(_lastHover, EVENT.DBLCLICK, event);
10670                }
10671            }
10672            this._mousemoveHandler(event);
10673        },
10674        mousewheel: function (event, manually) {
10675            if (!isZRenderElement(event) && !manually) {
10676                return;
10677            }
10678            event = this._zrenderEventFixed(event);
10679            var delta = event.wheelDelta || -event.detail;
10680            var scale = delta > 0 ? 1.1 : 1 / 1.1;
10681            var needsRefresh = false;
10682            var mouseX = this._mouseX;
10683            var mouseY = this._mouseY;
10684            this.painter.eachBuildinLayer(function (layer) {
10685                var pos = layer.position;
10686                if (layer.zoomable) {
10687                    layer.__zoom = layer.__zoom || 1;
10688                    var newZoom = layer.__zoom;
10689                    newZoom *= scale;
10690                    newZoom = Math.max(Math.min(layer.maxZoom, newZoom), layer.minZoom);
10691                    scale = newZoom / layer.__zoom;
10692                    layer.__zoom = newZoom;
10693                    pos[0] -= (mouseX - pos[0]) * (scale - 1);
10694                    pos[1] -= (mouseY - pos[1]) * (scale - 1);
10695                    layer.scale[0] *= scale;
10696                    layer.scale[1] *= scale;
10697                    layer.dirty = true;
10698                    needsRefresh = true;
10699                    eventTool.stop(event);
10700                }
10701            });
10702            if (needsRefresh) {
10703                this.painter.refresh();
10704            }
10705            this._dispatchAgency(this._lastHover, EVENT.MOUSEWHEEL, event);
10706            this._mousemoveHandler(event);
10707        },
10708        mousemove: function (event, manually) {
10709            if (!isZRenderElement(event) && !manually) {
10710                return;
10711            }
10712            if (this.painter.isLoading()) {
10713                return;
10714            }
10715            event = this._zrenderEventFixed(event);
10716            this._lastX = this._mouseX;
10717            this._lastY = this._mouseY;
10718            this._mouseX = eventTool.getX(event);
10719            this._mouseY = eventTool.getY(event);
10720            var dx = this._mouseX - this._lastX;
10721            var dy = this._mouseY - this._lastY;
10722            this._processDragStart(event);
10723            this._hasfound = 0;
10724            this._event = event;
10725            this._iterateAndFindHover();
10726            if (!this._hasfound) {
10727                if (!this._draggingTarget || this._lastHover && this._lastHover != this._draggingTarget) {
10728                    this._processOutShape(event);
10729                    this._processDragLeave(event);
10730                }
10731                this._lastHover = null;
10732                this.storage.delHover();
10733                this.painter.clearHover();
10734            }
10735            var cursor = 'default';
10736            if (this._draggingTarget) {
10737                this.storage.drift(this._draggingTarget.id, dx, dy);
10738                this._draggingTarget.modSelf();
10739                this.storage.addHover(this._draggingTarget);
10740                this._clickThreshold++;
10741            } else if (this._isMouseDown) {
10742                var needsRefresh = false;
10743                this.painter.eachBuildinLayer(function (layer) {
10744                    if (layer.panable) {
10745                        cursor = 'move';
10746                        layer.position[0] += dx;
10747                        layer.position[1] += dy;
10748                        needsRefresh = true;
10749                        layer.dirty = true;
10750                    }
10751                });
10752                if (needsRefresh) {
10753                    this.painter.refresh();
10754                }
10755            }
10756            if (this._draggingTarget || this._hasfound && this._lastHover.draggable) {
10757                cursor = 'move';
10758            } else if (this._hasfound && this._lastHover.clickable) {
10759                cursor = 'pointer';
10760            }
10761            this.root.style.cursor = cursor;
10762            this._dispatchAgency(this._lastHover, EVENT.MOUSEMOVE, event);
10763            if (this._draggingTarget || this._hasfound || this.storage.hasHoverShape()) {
10764                this.painter.refreshHover();
10765            }
10766        },
10767        mouseout: function (event, manually) {
10768            if (!isZRenderElement(event) && !manually) {
10769                return;
10770            }
10771            event = this._zrenderEventFixed(event);
10772            var element = event.toElement || event.relatedTarget;
10773            if (element != this.root) {
10774                while (element && element.nodeType != 9) {
10775                    if (element == this.root) {
10776                        this._mousemoveHandler(event);
10777                        return;
10778                    }
10779                    element = element.parentNode;
10780                }
10781            }
10782            event.zrenderX = this._lastX;
10783            event.zrenderY = this._lastY;
10784            this.root.style.cursor = 'default';
10785            this._isMouseDown = 0;
10786            this._processOutShape(event);
10787            this._processDrop(event);
10788            this._processDragEnd(event);
10789            if (!this.painter.isLoading()) {
10790                this.painter.refreshHover();
10791            }
10792            this.dispatch(EVENT.GLOBALOUT, event);
10793        },
10794        mousedown: function (event, manually) {
10795            if (!isZRenderElement(event) && !manually) {
10796                return;
10797            }
10798            this._clickThreshold = 0;
10799            if (this._lastDownButton == 2) {
10800                this._lastDownButton = event.button;
10801                this._mouseDownTarget = null;
10802                return;
10803            }
10804            this._lastMouseDownMoment = new Date();
10805            event = this._zrenderEventFixed(event);
10806            this._isMouseDown = 1;
10807            this._mouseDownTarget = this._lastHover;
10808            this._dispatchAgency(this._lastHover, EVENT.MOUSEDOWN, event);
10809            this._lastDownButton = event.button;
10810        },
10811        mouseup: function (event, manually) {
10812            if (!isZRenderElement(event) && !manually) {
10813                return;
10814            }
10815            event = this._zrenderEventFixed(event);
10816            this.root.style.cursor = 'default';
10817            this._isMouseDown = 0;
10818            this._mouseDownTarget = null;
10819            this._dispatchAgency(this._lastHover, EVENT.MOUSEUP, event);
10820            this._processDrop(event);
10821            this._processDragEnd(event);
10822        },
10823        touchstart: function (event, manually) {
10824            if (!isZRenderElement(event) && !manually) {
10825                return;
10826            }
10827            event = this._zrenderEventFixed(event, true);
10828            this._lastTouchMoment = new Date();
10829            this._mobileFindFixed(event);
10830            this._mousedownHandler(event);
10831        },
10832        touchmove: function (event, manually) {
10833            if (!isZRenderElement(event) && !manually) {
10834                return;
10835            }
10836            event = this._zrenderEventFixed(event, true);
10837            this._mousemoveHandler(event);
10838            if (this._isDragging) {
10839                eventTool.stop(event);
10840            }
10841        },
10842        touchend: function (event, manually) {
10843            if (!isZRenderElement(event) && !manually) {
10844                return;
10845            }
10846            event = this._zrenderEventFixed(event, true);
10847            this._mouseupHandler(event);
10848            var now = new Date();
10849            if (now - this._lastTouchMoment < EVENT.touchClickDelay) {
10850                this._mobileFindFixed(event);
10851                this._clickHandler(event);
10852                if (now - this._lastClickMoment < EVENT.touchClickDelay / 2) {
10853                    this._dblclickHandler(event);
10854                    if (this._lastHover && this._lastHover.clickable) {
10855                        eventTool.stop(event);
10856                    }
10857                }
10858                this._lastClickMoment = now;
10859            }
10860            this.painter.clearHover();
10861        }
10862    };
10863    function bind2Arg(handler, context) {
10864        return function (arg1, arg2) {
10865            return handler.call(context, arg1, arg2);
10866        };
10867    }
10868    function bind3Arg(handler, context) {
10869        return function (arg1, arg2, arg3) {
10870            return handler.call(context, arg1, arg2, arg3);
10871        };
10872    }
10873    function initDomHandler(instance) {
10874        var len = domHandlerNames.length;
10875        while (len--) {
10876            var name = domHandlerNames[len];
10877            instance['_' + name + 'Handler'] = bind2Arg(domHandlers[name], instance);
10878        }
10879    }
10880    var Handler = function (root, storage, painter) {
10881        Eventful.call(this);
10882        this.root = root;
10883        this.storage = storage;
10884        this.painter = painter;
10885        this._lastX = this._lastY = this._mouseX = this._mouseY = 0;
10886        this._findHover = bind3Arg(findHover, this);
10887        this._domHover = painter.getDomHover();
10888        initDomHandler(this);
10889        if (window.addEventListener) {
10890            window.addEventListener('resize', this._resizeHandler);
10891            if (env.os.tablet || env.os.phone) {
10892                root.addEventListener('touchstart', this._touchstartHandler);
10893                root.addEventListener('touchmove', this._touchmoveHandler);
10894                root.addEventListener('touchend', this._touchendHandler);
10895            } else {
10896                root.addEventListener('click', this._clickHandler);
10897                root.addEventListener('dblclick', this._dblclickHandler);
10898                root.addEventListener('mousewheel', this._mousewheelHandler);
10899                root.addEventListener('mousemove', this._mousemoveHandler);
10900                root.addEventListener('mousedown', this._mousedownHandler);
10901                root.addEventListener('mouseup', this._mouseupHandler);
10902            }
10903            root.addEventListener('DOMMouseScroll', this._mousewheelHandler);
10904            root.addEventListener('mouseout', this._mouseoutHandler);
10905        } else {
10906            window.attachEvent('onresize', this._resizeHandler);
10907            root.attachEvent('onclick', this._clickHandler);
10908            root.ondblclick = this._dblclickHandler;
10909            root.attachEvent('onmousewheel', this._mousewheelHandler);
10910            root.attachEvent('onmousemove', this._mousemoveHandler);
10911            root.attachEvent('onmouseout', this._mouseoutHandler);
10912            root.attachEvent('onmousedown', this._mousedownHandler);
10913            root.attachEvent('onmouseup', this._mouseupHandler);
10914        }
10915    };
10916    Handler.prototype.on = function (eventName, handler, context) {
10917        this.bind(eventName, handler, context);
10918        return this;
10919    };
10920    Handler.prototype.un = function (eventName, handler) {
10921        this.unbind(eventName, handler);
10922        return this;
10923    };
10924    Handler.prototype.trigger = function (eventName, eventArgs) {
10925        switch (eventName) {
10926        case EVENT.RESIZE:
10927        case EVENT.CLICK:
10928        case EVENT.DBLCLICK:
10929        case EVENT.MOUSEWHEEL:
10930        case EVENT.MOUSEMOVE:
10931        case EVENT.MOUSEDOWN:
10932        case EVENT.MOUSEUP:
10933        case EVENT.MOUSEOUT:
10934            this['_' + eventName + 'Handler'](eventArgs, true);
10935            break;
10936        }
10937    };
10938    Handler.prototype.dispose = function () {
10939        var root = this.root;
10940        if (window.removeEventListener) {
10941            window.removeEventListener('resize', this._resizeHandler);
10942            if (env.os.tablet || env.os.phone) {
10943                root.removeEventListener('touchstart', this._touchstartHandler);
10944                root.removeEventListener('touchmove', this._touchmoveHandler);
10945                root.removeEventListener('touchend', this._touchendHandler);
10946            } else {
10947                root.removeEventListener('click', this._clickHandler);
10948                root.removeEventListener('dblclick', this._dblclickHandler);
10949                root.removeEventListener('mousewheel', this._mousewheelHandler);
10950                root.removeEventListener('mousemove', this._mousemoveHandler);
10951                root.removeEventListener('mousedown', this._mousedownHandler);
10952                root.removeEventListener('mouseup', this._mouseupHandler);
10953            }
10954            root.removeEventListener('DOMMouseScroll', this._mousewheelHandler);
10955            root.removeEventListener('mouseout', this._mouseoutHandler);
10956        } else {
10957            window.detachEvent('onresize', this._resizeHandler);
10958            root.detachEvent('onclick', this._clickHandler);
10959            root.detachEvent('dblclick', this._dblclickHandler);
10960            root.detachEvent('onmousewheel', this._mousewheelHandler);
10961            root.detachEvent('onmousemove', this._mousemoveHandler);
10962            root.detachEvent('onmouseout', this._mouseoutHandler);
10963            root.detachEvent('onmousedown', this._mousedownHandler);
10964            root.detachEvent('onmouseup', this._mouseupHandler);
10965        }
10966        this.root = this._domHover = this.storage = this.painter = null;
10967        this.un();
10968    };
10969    Handler.prototype._processDragStart = function (event) {
10970        var _lastHover = this._lastHover;
10971        if (this._isMouseDown && _lastHover && _lastHover.draggable && !this._draggingTarget && this._mouseDownTarget == _lastHover) {
10972            if (_lastHover.dragEnableTime && new Date() - this._lastMouseDownMoment < _lastHover.dragEnableTime) {
10973                return;
10974            }
10975            var _draggingTarget = _lastHover;
10976            this._draggingTarget = _draggingTarget;
10977            this._isDragging = 1;
10978            _draggingTarget.invisible = true;
10979            this.storage.mod(_draggingTarget.id);
10980            this._dispatchAgency(_draggingTarget, EVENT.DRAGSTART, event);
10981            this.painter.refresh();
10982        }
10983    };
10984    Handler.prototype._processDragEnter = function (event) {
10985        if (this._draggingTarget) {
10986            this._dispatchAgency(this._lastHover, EVENT.DRAGENTER, event, this._draggingTarget);
10987        }
10988    };
10989    Handler.prototype._processDragOver = function (event) {
10990        if (this._draggingTarget) {
10991            this._dispatchAgency(this._lastHover, EVENT.DRAGOVER, event, this._draggingTarget);
10992        }
10993    };
10994    Handler.prototype._processDragLeave = function (event) {
10995        if (this._draggingTarget) {
10996            this._dispatchAgency(this._lastHover, EVENT.DRAGLEAVE, event, this._draggingTarget);
10997        }
10998    };
10999    Handler.prototype._processDrop = function (event) {
11000        if (this._draggingTarget) {
11001            this._draggingTarget.invisible = false;
11002            this.storage.mod(this._draggingTarget.id);
11003            this.painter.refresh();
11004            this._dispatchAgency(this._lastHover, EVENT.DROP, event, this._draggingTarget);
11005        }
11006    };
11007    Handler.prototype._processDragEnd = function (event) {
11008        if (this._draggingTarget) {
11009            this._dispatchAgency(this._draggingTarget, EVENT.DRAGEND, event);
11010            this._lastHover = null;
11011        }
11012        this._isDragging = 0;
11013        this._draggingTarget = null;
11014    };
11015    Handler.prototype._processOverShape = function (event) {
11016        this._dispatchAgency(this._lastHover, EVENT.MOUSEOVER, event);
11017    };
11018    Handler.prototype._processOutShape = function (event) {
11019        this._dispatchAgency(this._lastHover, EVENT.MOUSEOUT, event);
11020    };
11021    Handler.prototype._dispatchAgency = function (targetShape, eventName, event, draggedShape) {
11022        var eventHandler = 'on' + eventName;
11023        var eventPacket = {
11024            type: eventName,
11025            event: event,
11026            target: targetShape,
11027            cancelBubble: false
11028        };
11029        var el = targetShape;
11030        if (draggedShape) {
11031            eventPacket.dragged = draggedShape;
11032        }
11033        while (el) {
11034            el[eventHandler] && (eventPacket.cancelBubble = el[eventHandler](eventPacket));
11035            el.dispatch(eventName, eventPacket);
11036            el = el.parent;
11037            if (eventPacket.cancelBubble) {
11038                break;
11039            }
11040        }
11041        if (targetShape) {
11042            if (!eventPacket.cancelBubble) {
11043                this.dispatch(eventName, eventPacket);
11044            }
11045        } else if (!draggedShape) {
11046            var eveObj = {
11047                type: eventName,
11048                event: event
11049            };
11050            this.dispatch(eventName, eveObj);
11051            this.painter.eachOtherLayer(function (layer) {
11052                if (typeof layer[eventHandler] == 'function') {
11053                    layer[eventHandler](eveObj);
11054                }
11055                if (layer.dispatch) {
11056                    layer.dispatch(eventName, eveObj);
11057                }
11058            });
11059        }
11060    };
11061    Handler.prototype._iterateAndFindHover = function () {
11062        var invTransform = mat2d.create();
11063        return function () {
11064            var list = this.storage.getShapeList();
11065            var currentZLevel;
11066            var currentLayer;
11067            var tmp = [
11068                0,
11069                0
11070            ];
11071            for (var i = list.length - 1; i >= 0; i--) {
11072                var shape = list[i];
11073                if (currentZLevel !== shape.zlevel) {
11074                    currentLayer = this.painter.getLayer(shape.zlevel, currentLayer);
11075                    tmp[0] = this._mouseX;
11076                    tmp[1] = this._mouseY;
11077                    if (currentLayer.needTransform) {
11078                        mat2d.invert(invTransform, currentLayer.transform);
11079                        vec2.applyTransform(tmp, tmp, invTransform);
11080                    }
11081                }
11082                if (this._findHover(shape, tmp[0], tmp[1])) {
11083                    break;
11084                }
11085            }
11086        };
11087    }();
11088    var MOBILE_TOUCH_OFFSETS = [
11089        { x: 10 },
11090        { x: -20 },
11091        {
11092            x: 10,
11093            y: 10
11094        },
11095        { y: -20 }
11096    ];
11097    Handler.prototype._mobileFindFixed = function (event) {
11098        this._lastHover = null;
11099        this._mouseX = event.zrenderX;
11100        this._mouseY = event.zrenderY;
11101        this._event = event;
11102        this._iterateAndFindHover();
11103        for (var i = 0; !this._lastHover && i < MOBILE_TOUCH_OFFSETS.length; i++) {
11104            var offset = MOBILE_TOUCH_OFFSETS[i];
11105            offset.x && (this._mouseX += offset.x);
11106            offset.y && (this._mouseY += offset.y);
11107            this._iterateAndFindHover();
11108        }
11109        if (this._lastHover) {
11110            event.zrenderX = this._mouseX;
11111            event.zrenderY = this._mouseY;
11112        }
11113    };
11114    function findHover(shape, x, y) {
11115        if (this._draggingTarget && this._draggingTarget.id == shape.id || shape.isSilent()) {
11116            return false;
11117        }
11118        var event = this._event;
11119        if (shape.isCover(x, y)) {
11120            if (shape.hoverable) {
11121                this.storage.addHover(shape);
11122            }
11123            var p = shape.parent;
11124            while (p) {
11125                if (p.clipShape && !p.clipShape.isCover(this._mouseX, this._mouseY)) {
11126                    return false;
11127                }
11128                p = p.parent;
11129            }
11130            if (this._lastHover != shape) {
11131                this._processOutShape(event);
11132                this._processDragLeave(event);
11133                this._lastHover = shape;
11134                this._processDragEnter(event);
11135            }
11136            this._processOverShape(event);
11137            this._processDragOver(event);
11138            this._hasfound = 1;
11139            return true;
11140        }
11141        return false;
11142    }
11143    Handler.prototype._zrenderEventFixed = function (event, isTouch) {
11144        if (event.zrenderFixed) {
11145            return event;
11146        }
11147        if (!isTouch) {
11148            event = event || window.event;
11149            var target = event.toElement || event.relatedTarget || event.srcElement || event.target;
11150            if (target && target != this._domHover) {
11151                event.zrenderX = (typeof event.offsetX != 'undefined' ? event.offsetX : event.layerX) + target.offsetLeft;
11152                event.zrenderY = (typeof event.offsetY != 'undefined' ? event.offsetY : event.layerY) + target.offsetTop;
11153            }
11154        } else {
11155            var touch = event.type != 'touchend' ? event.targetTouches[0] : event.changedTouches[0];
11156            if (touch) {
11157                var rBounding = this.painter._domRoot.getBoundingClientRect();
11158                event.zrenderX = touch.clientX - rBounding.left;
11159                event.zrenderY = touch.clientY - rBounding.top;
11160            }
11161        }
11162        event.zrenderFixed = 1;
11163        return event;
11164    };
11165    util.merge(Handler.prototype, Eventful.prototype, true);
11166    return Handler;
11167});define('zrender/Painter', [
11168    'require',
11169    './config',
11170    './tool/util',
11171    './tool/log',
11172    './loadingEffect/Base',
11173    './Layer',
11174    './shape/Image'
11175], function (require) {
11176    'use strict';
11177    var config = require('./config');
11178    var util = require('./tool/util');
11179    var log = require('./tool/log');
11180    var BaseLoadingEffect = require('./loadingEffect/Base');
11181    var Layer = require('./Layer');
11182    function returnFalse() {
11183        return false;
11184    }
11185    function doNothing() {
11186    }
11187    function isLayerValid(layer) {
11188        if (!layer) {
11189            return false;
11190        }
11191        if (layer.isBuildin) {
11192            return true;
11193        }
11194        if (typeof layer.resize !== 'function' || typeof layer.refresh !== 'function') {
11195            return false;
11196        }
11197        return true;
11198    }
11199    var Painter = function (root, storage) {
11200        this.root = root;
11201        root.style['-webkit-tap-highlight-color'] = 'transparent';
11202        root.style['-webkit-user-select'] = 'none';
11203        root.style['user-select'] = 'none';
11204        root.style['-webkit-touch-callout'] = 'none';
11205        this.storage = storage;
11206        root.innerHTML = '';
11207        this._width = this._getWidth();
11208        this._height = this._getHeight();
11209        var domRoot = document.createElement('div');
11210        this._domRoot = domRoot;
11211        domRoot.style.position = 'relative';
11212        domRoot.style.overflow = 'hidden';
11213        domRoot.style.width = this._width + 'px';
11214        domRoot.style.height = this._height + 'px';
11215        root.appendChild(domRoot);
11216        this._layers = {};
11217        this._zlevelList = [];
11218        this._layerConfig = {};
11219        this._loadingEffect = new BaseLoadingEffect({});
11220        this.shapeToImage = this._createShapeToImageProcessor();
11221        this._bgDom = document.createElement('div');
11222        this._bgDom.style.cssText = [
11223            'position:absolute;left:0px;top:0px;width:',
11224            this._width,
11225            'px;height:',
11226            this._height + 'px;',
11227            '-webkit-user-select:none;user-select;none;',
11228            '-webkit-touch-callout:none;'
11229        ].join('');
11230        this._bgDom.setAttribute('data-zr-dom-id', 'bg');
11231        this._bgDom.className = config.elementClassName;
11232        domRoot.appendChild(this._bgDom);
11233        this._bgDom.onselectstart = returnFalse;
11234        var hoverLayer = new Layer('_zrender_hover_', this);
11235        this._layers['hover'] = hoverLayer;
11236        domRoot.appendChild(hoverLayer.dom);
11237        hoverLayer.initContext();
11238        hoverLayer.dom.onselectstart = returnFalse;
11239        hoverLayer.dom.style['-webkit-user-select'] = 'none';
11240        hoverLayer.dom.style['user-select'] = 'none';
11241        hoverLayer.dom.style['-webkit-touch-callout'] = 'none';
11242        this.refreshNextFrame = null;
11243    };
11244    Painter.prototype.render = function (callback) {
11245        if (this.isLoading()) {
11246            this.hideLoading();
11247        }
11248        this.refresh(callback, true);
11249        return this;
11250    };
11251    Painter.prototype.refresh = function (callback, paintAll) {
11252        var list = this.storage.getShapeList(true);
11253        this._paintList(list, paintAll);
11254        for (var i = 0; i < this._zlevelList.length; i++) {
11255            var z = this._zlevelList[i];
11256            var layer = this._layers[z];
11257            if (!layer.isBuildin && layer.refresh) {
11258                layer.refresh();
11259            }
11260        }
11261        if (typeof callback == 'function') {
11262            callback();
11263        }
11264        return this;
11265    };
11266    Painter.prototype._preProcessLayer = function (layer) {
11267        layer.unusedCount++;
11268        layer.updateTransform();
11269    };
11270    Painter.prototype._postProcessLayer = function (layer) {
11271        layer.dirty = false;
11272        if (layer.unusedCount == 1) {
11273            layer.clear();
11274        }
11275    };
11276    Painter.prototype._paintList = function (list, paintAll) {
11277        if (typeof paintAll == 'undefined') {
11278            paintAll = false;
11279        }
11280        this._updateLayerStatus(list);
11281        var currentLayer;
11282        var currentZLevel;
11283        var ctx;
11284        this.eachBuildinLayer(this._preProcessLayer);
11285        for (var i = 0, l = list.length; i < l; i++) {
11286            var shape = list[i];
11287            if (currentZLevel !== shape.zlevel) {
11288                if (currentLayer) {
11289                    if (currentLayer.needTransform) {
11290                        ctx.restore();
11291                    }
11292                    ctx.flush && ctx.flush();
11293                }
11294                currentZLevel = shape.zlevel;
11295                currentLayer = this.getLayer(currentZLevel);
11296                if (!currentLayer.isBuildin) {
11297                    log('ZLevel ' + currentZLevel + ' has been used by unkown layer ' + currentLayer.id);
11298                }
11299                ctx = currentLayer.ctx;
11300                currentLayer.unusedCount = 0;
11301                if (currentLayer.dirty || paintAll) {
11302                    currentLayer.clear();
11303                }
11304                if (currentLayer.needTransform) {
11305                    ctx.save();
11306                    currentLayer.setTransform(ctx);
11307                }
11308            }
11309            if ((currentLayer.dirty || paintAll) && !shape.invisible) {
11310                if (!shape.onbrush || shape.onbrush && !shape.onbrush(ctx, false)) {
11311                    if (config.catchBrushException) {
11312                        try {
11313                            shape.brush(ctx, false, this.refreshNextFrame);
11314                        } catch (error) {
11315                            log(error, 'brush error of ' + shape.type, shape);
11316                        }
11317                    } else {
11318                        shape.brush(ctx, false, this.refreshNextFrame);
11319                    }
11320                }
11321            }
11322            shape.__dirty = false;
11323        }
11324        if (currentLayer) {
11325            if (currentLayer.needTransform) {
11326                ctx.restore();
11327            }
11328            ctx.flush && ctx.flush();
11329        }
11330        this.eachBuildinLayer(this._postProcessLayer);
11331    };
11332    Painter.prototype.getLayer = function (zlevel) {
11333        var layer = this._layers[zlevel];
11334        if (!layer) {
11335            layer = new Layer(zlevel, this);
11336            layer.isBuildin = true;
11337            if (this._layerConfig[zlevel]) {
11338                util.merge(layer, this._layerConfig[zlevel], true);
11339            }
11340            layer.updateTransform();
11341            this.insertLayer(zlevel, layer);
11342            layer.initContext();
11343        }
11344        return layer;
11345    };
11346    Painter.prototype.insertLayer = function (zlevel, layer) {
11347        if (this._layers[zlevel]) {
11348            log('ZLevel ' + zlevel + ' has been used already');
11349            return;
11350        }
11351        if (!isLayerValid(layer)) {
11352            log('Layer of zlevel ' + zlevel + ' is not valid');
11353            return;
11354        }
11355        var len = this._zlevelList.length;
11356        var prevLayer = null;
11357        var i = -1;
11358        if (len > 0 && zlevel > this._zlevelList[0]) {
11359            for (i = 0; i < len - 1; i++) {
11360                if (this._zlevelList[i] < zlevel && this._zlevelList[i + 1] > zlevel) {
11361                    break;
11362                }
11363            }
11364            prevLayer = this._layers[this._zlevelList[i]];
11365        }
11366        this._zlevelList.splice(i + 1, 0, zlevel);
11367        var prevDom = prevLayer ? prevLayer.dom : this._bgDom;
11368        if (prevDom.nextSibling) {
11369            prevDom.parentNode.insertBefore(layer.dom, prevDom.nextSibling);
11370        } else {
11371            prevDom.parentNode.appendChild(layer.dom);
11372        }
11373        this._layers[zlevel] = layer;
11374    };
11375    Painter.prototype.eachLayer = function (cb, context) {
11376        for (var i = 0; i < this._zlevelList.length; i++) {
11377            var z = this._zlevelList[i];
11378            cb.call(context, this._layers[z], z);
11379        }
11380    };
11381    Painter.prototype.eachBuildinLayer = function (cb, context) {
11382        for (var i = 0; i < this._zlevelList.length; i++) {
11383            var z = this._zlevelList[i];
11384            var layer = this._layers[z];
11385            if (layer.isBuildin) {
11386                cb.call(context, layer, z);
11387            }
11388        }
11389    };
11390    Painter.prototype.eachOtherLayer = function (cb, context) {
11391        for (var i = 0; i < this._zlevelList.length; i++) {
11392            var z = this._zlevelList[i];
11393            var layer = this._layers[z];
11394            if (!layer.isBuildin) {
11395                cb.call(context, layer, z);
11396            }
11397        }
11398    };
11399    Painter.prototype.getLayers = function () {
11400        return this._layers;
11401    };
11402    Painter.prototype._updateLayerStatus = function (list) {
11403        var layers = this._layers;
11404        var elCounts = {};
11405        this.eachBuildinLayer(function (layer, z) {
11406            elCounts[z] = layer.elCount;
11407            layer.elCount = 0;
11408        });
11409        for (var i = 0, l = list.length; i < l; i++) {
11410            var shape = list[i];
11411            var zlevel = shape.zlevel;
11412            var layer = layers[zlevel];
11413            if (layer) {
11414                layer.elCount++;
11415                if (layer.dirty) {
11416                    continue;
11417                }
11418                layer.dirty = shape.__dirty;
11419            }
11420        }
11421        this.eachBuildinLayer(function (layer, z) {
11422            if (elCounts[z] !== layer.elCount) {
11423                layer.dirty = true;
11424            }
11425        });
11426    };
11427    Painter.prototype.refreshShapes = function (shapeList, callback) {
11428        for (var i = 0, l = shapeList.length; i < l; i++) {
11429            var shape = shapeList[i];
11430            shape.modSelf();
11431        }
11432        this.refresh(callback);
11433        return this;
11434    };
11435    Painter.prototype.setLoadingEffect = function (loadingEffect) {
11436        this._loadingEffect = loadingEffect;
11437        return this;
11438    };
11439    Painter.prototype.clear = function () {
11440        this.eachBuildinLayer(this._clearLayer);
11441        return this;
11442    };
11443    Painter.prototype._clearLayer = function (layer) {
11444        layer.clear();
11445    };
11446    Painter.prototype.modLayer = function (zlevel, config) {
11447        if (config) {
11448            if (!this._layerConfig[zlevel]) {
11449                this._layerConfig[zlevel] = config;
11450            } else {
11451                util.merge(this._layerConfig[zlevel], config, true);
11452            }
11453            var layer = this._layers[zlevel];
11454            if (layer) {
11455                util.merge(layer, this._layerConfig[zlevel], true);
11456            }
11457        }
11458    };
11459    Painter.prototype.delLayer = function (zlevel) {
11460        var layer = this._layers[zlevel];
11461        if (!layer) {
11462            return;
11463        }
11464        this.modLayer(zlevel, {
11465            position: layer.position,
11466            rotation: layer.rotation,
11467            scale: layer.scale
11468        });
11469        layer.dom.parentNode.removeChild(layer.dom);
11470        delete this._layers[zlevel];
11471        this._zlevelList.splice(util.indexOf(this._zlevelList, zlevel), 1);
11472    };
11473    Painter.prototype.refreshHover = function () {
11474        this.clearHover();
11475        var list = this.storage.getHoverShapes(true);
11476        for (var i = 0, l = list.length; i < l; i++) {
11477            this._brushHover(list[i]);
11478        }
11479        var ctx = this._layers.hover.ctx;
11480        ctx.flush && ctx.flush();
11481        this.storage.delHover();
11482        return this;
11483    };
11484    Painter.prototype.clearHover = function () {
11485        var hover = this._layers.hover;
11486        hover && hover.clear();
11487        return this;
11488    };
11489    Painter.prototype.showLoading = function (loadingEffect) {
11490        this._loadingEffect && this._loadingEffect.stop();
11491        loadingEffect && this.setLoadingEffect(loadingEffect);
11492        this._loadingEffect.start(this);
11493        this.loading = true;
11494        return this;
11495    };
11496    Painter.prototype.hideLoading = function () {
11497        this._loadingEffect.stop();
11498        this.clearHover();
11499        this.loading = false;
11500        return this;
11501    };
11502    Painter.prototype.isLoading = function () {
11503        return this.loading;
11504    };
11505    Painter.prototype.resize = function () {
11506        var domRoot = this._domRoot;
11507        domRoot.style.display = 'none';
11508        var width = this._getWidth();
11509        var height = this._getHeight();
11510        domRoot.style.display = '';
11511        if (this._width != width || height != this._height) {
11512            this._width = width;
11513            this._height = height;
11514            domRoot.style.width = width + 'px';
11515            domRoot.style.height = height + 'px';
11516            for (var id in this._layers) {
11517                this._layers[id].resize(width, height);
11518            }
11519            this.refresh(null, true);
11520        }
11521        return this;
11522    };
11523    Painter.prototype.clearLayer = function (zLevel) {
11524        var layer = this._layers[zLevel];
11525        if (layer) {
11526            layer.clear();
11527        }
11528    };
11529    Painter.prototype.dispose = function () {
11530        if (this.isLoading()) {
11531            this.hideLoading();
11532        }
11533        this.root.innerHTML = '';
11534        this.root = this.storage = this._domRoot = this._layers = null;
11535    };
11536    Painter.prototype.getDomHover = function () {
11537        return this._layers.hover.dom;
11538    };
11539    Painter.prototype.toDataURL = function (type, backgroundColor, args) {
11540        if (window['G_vmlCanvasManager']) {
11541            return null;
11542        }
11543        var imageLayer = new Layer('image', this);
11544        this._bgDom.appendChild(imageLayer.dom);
11545        imageLayer.initContext();
11546        var ctx = imageLayer.ctx;
11547        imageLayer.clearColor = backgroundColor || '#fff';
11548        imageLayer.clear();
11549        var self = this;
11550        this.storage.iterShape(function (shape) {
11551            if (!shape.invisible) {
11552                if (!shape.onbrush || shape.onbrush && !shape.onbrush(ctx, false)) {
11553                    if (config.catchBrushException) {
11554                        try {
11555                            shape.brush(ctx, false, self.refreshNextFrame);
11556                        } catch (error) {
11557                            log(error, 'brush error of ' + shape.type, shape);
11558                        }
11559                    } else {
11560                        shape.brush(ctx, false, self.refreshNextFrame);
11561                    }
11562                }
11563            }
11564        }, {
11565            normal: 'up',
11566            update: true
11567        });
11568        var image = imageLayer.dom.toDataURL(type, args);
11569        ctx = null;
11570        this._bgDom.removeChild(imageLayer.dom);
11571        return image;
11572    };
11573    Painter.prototype.getWidth = function () {
11574        return this._width;
11575    };
11576    Painter.prototype.getHeight = function () {
11577        return this._height;
11578    };
11579    Painter.prototype._getWidth = function () {
11580        var root = this.root;
11581        var stl = root.currentStyle || document.defaultView.getComputedStyle(root);
11582        return ((root.clientWidth || parseInt(stl.width, 10)) - parseInt(stl.paddingLeft, 10) - parseInt(stl.paddingRight, 10)).toFixed(0) - 0;
11583    };
11584    Painter.prototype._getHeight = function () {
11585        var root = this.root;
11586        var stl = root.currentStyle || document.defaultView.getComputedStyle(root);
11587        return ((root.clientHeight || parseInt(stl.height, 10)) - parseInt(stl.paddingTop, 10) - parseInt(stl.paddingBottom, 10)).toFixed(0) - 0;
11588    };
11589    Painter.prototype._brushHover = function (shape) {
11590        var ctx = this._layers.hover.ctx;
11591        if (!shape.onbrush || shape.onbrush && !shape.onbrush(ctx, true)) {
11592            var layer = this.getLayer(shape.zlevel);
11593            if (layer.needTransform) {
11594                ctx.save();
11595                layer.setTransform(ctx);
11596            }
11597            if (config.catchBrushException) {
11598                try {
11599                    shape.brush(ctx, true, this.refreshNextFrame);
11600                } catch (error) {
11601                    log(error, 'hoverBrush error of ' + shape.type, shape);
11602                }
11603            } else {
11604                shape.brush(ctx, true, this.refreshNextFrame);
11605            }
11606            if (layer.needTransform) {
11607                ctx.restore();
11608            }
11609        }
11610    };
11611    Painter.prototype._shapeToImage = function (id, shape, width, height, devicePixelRatio) {
11612        var canvas = document.createElement('canvas');
11613        var ctx = canvas.getContext('2d');
11614        canvas.style.width = width + 'px';
11615        canvas.style.height = height + 'px';
11616        canvas.setAttribute('width', width * devicePixelRatio);
11617        canvas.setAttribute('height', height * devicePixelRatio);
11618        ctx.clearRect(0, 0, width * devicePixelRatio, height * devicePixelRatio);
11619        var shapeTransform = {
11620            position: shape.position,
11621            rotation: shape.rotation,
11622            scale: shape.scale
11623        };
11624        shape.position = [
11625            0,
11626            0,
11627            0
11628        ];
11629        shape.rotation = 0;
11630        shape.scale = [
11631            1,
11632            1
11633        ];
11634        if (shape) {
11635            shape.brush(ctx, false);
11636        }
11637        var ImageShape = require('./shape/Image');
11638        var imgShape = new ImageShape({
11639            id: id,
11640            style: {
11641                x: 0,
11642                y: 0,
11643                image: canvas
11644            }
11645        });
11646        if (shapeTransform.position != null) {
11647            imgShape.position = shape.position = shapeTransform.position;
11648        }
11649        if (shapeTransform.rotation != null) {
11650            imgShape.rotation = shape.rotation = shapeTransform.rotation;
11651        }
11652        if (shapeTransform.scale != null) {
11653            imgShape.scale = shape.scale = shapeTransform.scale;
11654        }
11655        return imgShape;
11656    };
11657    Painter.prototype._createShapeToImageProcessor = function () {
11658        if (window['G_vmlCanvasManager']) {
11659            return doNothing;
11660        }
11661        var me = this;
11662        return function (id, e, width, height) {
11663            return me._shapeToImage(id, e, width, height, config.devicePixelRatio);
11664        };
11665    };
11666    return Painter;
11667});define('zrender/Storage', [
11668    'require',
11669    './tool/util',
11670    './Group'
11671], function (require) {
11672    'use strict';
11673    var util = require('./tool/util');
11674    var Group = require('./Group');
11675    var defaultIterateOption = {
11676        hover: false,
11677        normal: 'down',
11678        update: false
11679    };
11680    function shapeCompareFunc(a, b) {
11681        if (a.zlevel == b.zlevel) {
11682            if (a.z == b.z) {
11683                return a.__renderidx - b.__renderidx;
11684            }
11685            return a.z - b.z;
11686        }
11687        return a.zlevel - b.zlevel;
11688    }
11689    var Storage = function () {
11690        this._elements = {};
11691        this._hoverElements = [];
11692        this._roots = [];
11693        this._shapeList = [];
11694        this._shapeListOffset = 0;
11695    };
11696    Storage.prototype.iterShape = function (fun, option) {
11697        if (!option) {
11698            option = defaultIterateOption;
11699        }
11700        if (option.hover) {
11701            for (var i = 0, l = this._hoverElements.length; i < l; i++) {
11702                var el = this._hoverElements[i];
11703                el.updateTransform();
11704                if (fun(el)) {
11705                    return this;
11706                }
11707            }
11708        }
11709        if (option.update) {
11710            this.updateShapeList();
11711        }
11712        switch (option.normal) {
11713        case 'down':
11714            var l = this._shapeList.length;
11715            while (l--) {
11716                if (fun(this._shapeList[l])) {
11717                    return this;
11718                }
11719            }
11720            break;
11721        default:
11722            for (var i = 0, l = this._shapeList.length; i < l; i++) {
11723                if (fun(this._shapeList[i])) {
11724                    return this;
11725                }
11726            }
11727            break;
11728        }
11729        return this;
11730    };
11731    Storage.prototype.getHoverShapes = function (update) {
11732        var hoverElements = [];
11733        for (var i = 0, l = this._hoverElements.length; i < l; i++) {
11734            hoverElements.push(this._hoverElements[i]);
11735            var target = this._hoverElements[i].hoverConnect;
11736            if (target) {
11737                var shape;
11738                target = target instanceof Array ? target : [target];
11739                for (var j = 0, k = target.length; j < k; j++) {
11740                    shape = target[j].id ? target[j] : this.get(target[j]);
11741                    if (shape) {
11742                        hoverElements.push(shape);
11743                    }
11744                }
11745            }
11746        }
11747        hoverElements.sort(shapeCompareFunc);
11748        if (update) {
11749            for (var i = 0, l = hoverElements.length; i < l; i++) {
11750                hoverElements[i].updateTransform();
11751            }
11752        }
11753        return hoverElements;
11754    };
11755    Storage.prototype.getShapeList = function (update) {
11756        if (update) {
11757            this.updateShapeList();
11758        }
11759        return this._shapeList;
11760    };
11761    Storage.prototype.updateShapeList = function () {
11762        this._shapeListOffset = 0;
11763        for (var i = 0, len = this._roots.length; i < len; i++) {
11764            var root = this._roots[i];
11765            this._updateAndAddShape(root);
11766        }
11767        this._shapeList.length = this._shapeListOffset;
11768        for (var i = 0, len = this._shapeList.length; i < len; i++) {
11769            this._shapeList[i].__renderidx = i;
11770        }
11771        this._shapeList.sort(shapeCompareFunc);
11772    };
11773    Storage.prototype._updateAndAddShape = function (el, clipShapes) {
11774        if (el.ignore) {
11775            return;
11776        }
11777        el.updateTransform();
11778        if (el.clipShape) {
11779            el.clipShape.parent = el;
11780            el.clipShape.updateTransform();
11781            if (clipShapes) {
11782                clipShapes = clipShapes.slice();
11783                clipShapes.push(el.clipShape);
11784            } else {
11785                clipShapes = [el.clipShape];
11786            }
11787        }
11788        if (el.type == 'group') {
11789            for (var i = 0; i < el._children.length; i++) {
11790                var child = el._children[i];
11791                child.__dirty = el.__dirty || child.__dirty;
11792                this._updateAndAddShape(child, clipShapes);
11793            }
11794            el.__dirty = false;
11795        } else {
11796            el.__clipShapes = clipShapes;
11797            this._shapeList[this._shapeListOffset++] = el;
11798        }
11799    };
11800    Storage.prototype.mod = function (el, params) {
11801        if (typeof el === 'string') {
11802            el = this._elements[el];
11803        }
11804        if (el) {
11805            el.modSelf();
11806            if (params) {
11807                if (params.parent || params._storage || params.__clipShapes) {
11808                    var target = {};
11809                    for (var name in params) {
11810                        if (name === 'parent' || name === '_storage' || name === '__clipShapes') {
11811                            continue;
11812                        }
11813                        if (params.hasOwnProperty(name)) {
11814                            target[name] = params[name];
11815                        }
11816                    }
11817                    util.merge(el, target, true);
11818                } else {
11819                    util.merge(el, params, true);
11820                }
11821            }
11822        }
11823        return this;
11824    };
11825    Storage.prototype.drift = function (shapeId, dx, dy) {
11826        var shape = this._elements[shapeId];
11827        if (shape) {
11828            shape.needTransform = true;
11829            if (shape.draggable === 'horizontal') {
11830                dy = 0;
11831            } else if (shape.draggable === 'vertical') {
11832                dx = 0;
11833            }
11834            if (!shape.ondrift || shape.ondrift && !shape.ondrift(dx, dy)) {
11835                shape.drift(dx, dy);
11836            }
11837        }
11838        return this;
11839    };
11840    Storage.prototype.addHover = function (shape) {
11841        shape.updateNeedTransform();
11842        this._hoverElements.push(shape);
11843        return this;
11844    };
11845    Storage.prototype.delHover = function () {
11846        this._hoverElements = [];
11847        return this;
11848    };
11849    Storage.prototype.hasHoverShape = function () {
11850        return this._hoverElements.length > 0;
11851    };
11852    Storage.prototype.addRoot = function (el) {
11853        if (this._elements[el.id]) {
11854            return;
11855        }
11856        if (el instanceof Group) {
11857            el.addChildrenToStorage(this);
11858        }
11859        this.addToMap(el);
11860        this._roots.push(el);
11861    };
11862    Storage.prototype.delRoot = function (elId) {
11863        if (typeof elId == 'undefined') {
11864            for (var i = 0; i < this._roots.length; i++) {
11865                var root = this._roots[i];
11866                if (root instanceof Group) {
11867                    root.delChildrenFromStorage(this);
11868                }
11869            }
11870            this._elements = {};
11871            this._hoverElements = [];
11872            this._roots = [];
11873            this._shapeList = [];
11874            this._shapeListOffset = 0;
11875            return;
11876        }
11877        if (elId instanceof Array) {
11878            for (var i = 0, l = elId.length; i < l; i++) {
11879                this.delRoot(elId[i]);
11880            }
11881            return;
11882        }
11883        var el;
11884        if (typeof elId == 'string') {
11885            el = this._elements[elId];
11886        } else {
11887            el = elId;
11888        }
11889        var idx = util.indexOf(this._roots, el);
11890        if (idx >= 0) {
11891            this.delFromMap(el.id);
11892            this._roots.splice(idx, 1);
11893            if (el instanceof Group) {
11894                el.delChildrenFromStorage(this);
11895            }
11896        }
11897    };
11898    Storage.prototype.addToMap = function (el) {
11899        if (el instanceof Group) {
11900            el._storage = this;
11901        }
11902        el.modSelf();
11903        this._elements[el.id] = el;
11904        return this;
11905    };
11906    Storage.prototype.get = function (elId) {
11907        return this._elements[elId];
11908    };
11909    Storage.prototype.delFromMap = function (elId) {
11910        var el = this._elements[elId];
11911        if (el) {
11912            delete this._elements[elId];
11913            if (el instanceof Group) {
11914                el._storage = null;
11915            }
11916        }
11917        return this;
11918    };
11919    Storage.prototype.dispose = function () {
11920        this._elements = this._renderList = this._roots = this._hoverElements = null;
11921    };
11922    return Storage;
11923});define('zrender/animation/Animation', [
11924    'require',
11925    './Clip',
11926    '../tool/color',
11927    '../tool/util',
11928    '../tool/event'
11929], function (require) {
11930    'use strict';
11931    var Clip = require('./Clip');
11932    var color = require('../tool/color');
11933    var util = require('../tool/util');
11934    var Dispatcher = require('../tool/event').Dispatcher;
11935    var requestAnimationFrame = window.requestAnimationFrame || window.msRequestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || function (func) {
11936        setTimeout(func, 16);
11937    };
11938    var arraySlice = Array.prototype.slice;
11939    var Animation = function (options) {
11940        options = options || {};
11941        this.stage = options.stage || {};
11942        this.onframe = options.onframe || function () {
11943        };
11944        this._clips = [];
11945        this._running = false;
11946        this._time = 0;
11947        Dispatcher.call(this);
11948    };
11949    Animation.prototype = {
11950        add: function (clip) {
11951            this._clips.push(clip);
11952        },
11953        remove: function (clip) {
11954            if (clip.__inStep) {
11955                clip.__needsRemove = true;
11956            } else {
11957                var idx = util.indexOf(this._clips, clip);
11958                if (idx >= 0) {
11959                    this._clips.splice(idx, 1);
11960                }
11961            }
11962        },
11963        _update: function () {
11964            var time = new Date().getTime();
11965            var delta = time - this._time;
11966            var clips = this._clips;
11967            var len = clips.length;
11968            var deferredEvents = [];
11969            var deferredClips = [];
11970            for (var i = 0; i < len; i++) {
11971                var clip = clips[i];
11972                clip.__inStep = true;
11973                var e = clip.step(time);
11974                clip.__inStep = false;
11975                if (e) {
11976                    deferredEvents.push(e);
11977                    deferredClips.push(clip);
11978                }
11979            }
11980            for (var i = 0; i < len;) {
11981                if (clips[i].__needsRemove) {
11982                    clips[i] = clips[len - 1];
11983                    clips.pop();
11984                    len--;
11985                } else {
11986                    i++;
11987                }
11988            }
11989            len = deferredEvents.length;
11990            for (var i = 0; i < len; i++) {
11991                deferredClips[i].fire(deferredEvents[i]);
11992            }
11993            this._time = time;
11994            this.onframe(delta);
11995            this.dispatch('frame', delta);
11996            if (this.stage.update) {
11997                this.stage.update();
11998            }
11999        },
12000        start: function () {
12001            var self = this;
12002            this._running = true;
12003            function step() {
12004                if (self._running) {
12005                    requestAnimationFrame(step);
12006                    self._update();
12007                }
12008            }
12009            this._time = new Date().getTime();
12010            requestAnimationFrame(step);
12011        },
12012        stop: function () {
12013            this._running = false;
12014        },
12015        clear: function () {
12016            this._clips = [];
12017        },
12018        animate: function (target, options) {
12019            options = options || {};
12020            var deferred = new Animator(target, options.loop, options.getter, options.setter);
12021            deferred.animation = this;
12022            return deferred;
12023        },
12024        constructor: Animation
12025    };
12026    util.merge(Animation.prototype, Dispatcher.prototype, true);
12027    function _defaultGetter(target, key) {
12028        return target[key];
12029    }
12030    function _defaultSetter(target, key, value) {
12031        target[key] = value;
12032    }
12033    function _interpolateNumber(p0, p1, percent) {
12034        return (p1 - p0) * percent + p0;
12035    }
12036    function _interpolateArray(p0, p1, percent, out, arrDim) {
12037        var len = p0.length;
12038        if (arrDim == 1) {
12039            for (var i = 0; i < len; i++) {
12040                out[i] = _interpolateNumber(p0[i], p1[i], percent);
12041            }
12042        } else {
12043            var len2 = p0[0].length;
12044            for (var i = 0; i < len; i++) {
12045                for (var j = 0; j < len2; j++) {
12046                    out[i][j] = _interpolateNumber(p0[i][j], p1[i][j], percent);
12047                }
12048            }
12049        }
12050    }
12051    function _isArrayLike(data) {
12052        switch (typeof data) {
12053        case 'undefined':
12054        case 'string':
12055            return false;
12056        }
12057        return typeof data.length !== 'undefined';
12058    }
12059    function _catmullRomInterpolateArray(p0, p1, p2, p3, t, t2, t3, out, arrDim) {
12060        var len = p0.length;
12061        if (arrDim == 1) {
12062            for (var i = 0; i < len; i++) {
12063                out[i] = _catmullRomInterpolate(p0[i], p1[i], p2[i], p3[i], t, t2, t3);
12064            }
12065        } else {
12066            var len2 = p0[0].length;
12067            for (var i = 0; i < len; i++) {
12068                for (var j = 0; j < len2; j++) {
12069                    out[i][j] = _catmullRomInterpolate(p0[i][j], p1[i][j], p2[i][j], p3[i][j], t, t2, t3);
12070                }
12071            }
12072        }
12073    }
12074    function _catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
12075        var v0 = (p2 - p0) * 0.5;
12076        var v1 = (p3 - p1) * 0.5;
12077        return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
12078    }
12079    function _cloneValue(value) {
12080        if (_isArrayLike(value)) {
12081            var len = value.length;
12082            if (_isArrayLike(value[0])) {
12083                var ret = [];
12084                for (var i = 0; i < len; i++) {
12085                    ret.push(arraySlice.call(value[i]));
12086                }
12087                return ret;
12088            } else {
12089                return arraySlice.call(value);
12090            }
12091        } else {
12092            return value;
12093        }
12094    }
12095    function rgba2String(rgba) {
12096        rgba[0] = Math.floor(rgba[0]);
12097        rgba[1] = Math.floor(rgba[1]);
12098        rgba[2] = Math.floor(rgba[2]);
12099        return 'rgba(' + rgba.join(',') + ')';
12100    }
12101    var Animator = function (target, loop, getter, setter) {
12102        this._tracks = {};
12103        this._target = target;
12104        this._loop = loop || false;
12105        this._getter = getter || _defaultGetter;
12106        this._setter = setter || _defaultSetter;
12107        this._clipCount = 0;
12108        this._delay = 0;
12109        this._doneList = [];
12110        this._onframeList = [];
12111        this._clipList = [];
12112    };
12113    Animator.prototype = {
12114        when: function (time, props) {
12115            for (var propName in props) {
12116                if (!this._tracks[propName]) {
12117                    this._tracks[propName] = [];
12118                    if (time !== 0) {
12119                        this._tracks[propName].push({
12120                            time: 0,
12121                            value: _cloneValue(this._getter(this._target, propName))
12122                        });
12123                    }
12124                }
12125                this._tracks[propName].push({
12126                    time: parseInt(time, 10),
12127                    value: props[propName]
12128                });
12129            }
12130            return this;
12131        },
12132        during: function (callback) {
12133            this._onframeList.push(callback);
12134            return this;
12135        },
12136        start: function (easing) {
12137            var self = this;
12138            var setter = this._setter;
12139            var getter = this._getter;
12140            var useSpline = easing === 'spline';
12141            var ondestroy = function () {
12142                self._clipCount--;
12143                if (self._clipCount === 0) {
12144                    self._tracks = {};
12145                    var len = self._doneList.length;
12146                    for (var i = 0; i < len; i++) {
12147                        self._doneList[i].call(self);
12148                    }
12149                }
12150            };
12151            var createTrackClip = function (keyframes, propName) {
12152                var trackLen = keyframes.length;
12153                if (!trackLen) {
12154                    return;
12155                }
12156                var firstVal = keyframes[0].value;
12157                var isValueArray = _isArrayLike(firstVal);
12158                var isValueColor = false;
12159                var arrDim = isValueArray && _isArrayLike(firstVal[0]) ? 2 : 1;
12160                keyframes.sort(function (a, b) {
12161                    return a.time - b.time;
12162                });
12163                var trackMaxTime;
12164                if (trackLen) {
12165                    trackMaxTime = keyframes[trackLen - 1].time;
12166                } else {
12167                    return;
12168                }
12169                var kfPercents = [];
12170                var kfValues = [];
12171                for (var i = 0; i < trackLen; i++) {
12172                    kfPercents.push(keyframes[i].time / trackMaxTime);
12173                    var value = keyframes[i].value;
12174                    if (typeof value == 'string') {
12175                        value = color.toArray(value);
12176                        if (value.length === 0) {
12177                            value[0] = value[1] = value[2] = 0;
12178                            value[3] = 1;
12179                        }
12180                        isValueColor = true;
12181                    }
12182                    kfValues.push(value);
12183                }
12184                var cacheKey = 0;
12185                var cachePercent = 0;
12186                var start;
12187                var i;
12188                var w;
12189                var p0;
12190                var p1;
12191                var p2;
12192                var p3;
12193                if (isValueColor) {
12194                    var rgba = [
12195                        0,
12196                        0,
12197                        0,
12198                        0
12199                    ];
12200                }
12201                var onframe = function (target, percent) {
12202                    if (percent < cachePercent) {
12203                        start = Math.min(cacheKey + 1, trackLen - 1);
12204                        for (i = start; i >= 0; i--) {
12205                            if (kfPercents[i] <= percent) {
12206                                break;
12207                            }
12208                        }
12209                        i = Math.min(i, trackLen - 2);
12210                    } else {
12211                        for (i = cacheKey; i < trackLen; i++) {
12212                            if (kfPercents[i] > percent) {
12213                                break;
12214                            }
12215                        }
12216                        i = Math.min(i - 1, trackLen - 2);
12217                    }
12218                    cacheKey = i;
12219                    cachePercent = percent;
12220                    var range = kfPercents[i + 1] - kfPercents[i];
12221                    if (range === 0) {
12222                        return;
12223                    } else {
12224                        w = (percent - kfPercents[i]) / range;
12225                    }
12226                    if (useSpline) {
12227                        p1 = kfValues[i];
12228                        p0 = kfValues[i === 0 ? i : i - 1];
12229                        p2 = kfValues[i > trackLen - 2 ? trackLen - 1 : i + 1];
12230                        p3 = kfValues[i > trackLen - 3 ? trackLen - 1 : i + 2];
12231                        if (isValueArray) {
12232                            _catmullRomInterpolateArray(p0, p1, p2, p3, w, w * w, w * w * w, getter(target, propName), arrDim);
12233                        } else {
12234                            var value;
12235                            if (isValueColor) {
12236                                value = _catmullRomInterpolateArray(p0, p1, p2, p3, w, w * w, w * w * w, rgba, 1);
12237                                value = rgba2String(rgba);
12238                            } else {
12239                                value = _catmullRomInterpolate(p0, p1, p2, p3, w, w * w, w * w * w);
12240                            }
12241                            setter(target, propName, value);
12242                        }
12243                    } else {
12244                        if (isValueArray) {
12245                            _interpolateArray(kfValues[i], kfValues[i + 1], w, getter(target, propName), arrDim);
12246                        } else {
12247                            var value;
12248                            if (isValueColor) {
12249                                _interpolateArray(kfValues[i], kfValues[i + 1], w, rgba, 1);
12250                                value = rgba2String(rgba);
12251                            } else {
12252                                value = _interpolateNumber(kfValues[i], kfValues[i + 1], w);
12253                            }
12254                            setter(target, propName, value);
12255                        }
12256                    }
12257                    for (i = 0; i < self._onframeList.length; i++) {
12258                        self._onframeList[i](target, percent);
12259                    }
12260                };
12261                var clip = new Clip({
12262                    target: self._target,
12263                    life: trackMaxTime,
12264                    loop: self._loop,
12265                    delay: self._delay,
12266                    onframe: onframe,
12267                    ondestroy: ondestroy
12268                });
12269                if (easing && easing !== 'spline') {
12270                    clip.easing = easing;
12271                }
12272                self._clipList.push(clip);
12273                self._clipCount++;
12274                self.animation.add(clip);
12275            };
12276            for (var propName in this._tracks) {
12277                createTrackClip(this._tracks[propName], propName);
12278            }
12279            return this;
12280        },
12281        stop: function () {
12282            for (var i = 0; i < this._clipList.length; i++) {
12283                var clip = this._clipList[i];
12284                this.animation.remove(clip);
12285            }
12286            this._clipList = [];
12287        },
12288        delay: function (time) {
12289            this._delay = time;
12290            return this;
12291        },
12292        done: function (cb) {
12293            if (cb) {
12294                this._doneList.push(cb);
12295            }
12296            return this;
12297        }
12298    };
12299    return Animation;
12300});define('zrender/tool/vector', [], function () {
12301    var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array;
12302    var vector = {
12303        create: function (x, y) {
12304            var out = new ArrayCtor(2);
12305            out[0] = x || 0;
12306            out[1] = y || 0;
12307            return out;
12308        },
12309        copy: function (out, v) {
12310            out[0] = v[0];
12311            out[1] = v[1];
12312            return out;
12313        },
12314        clone: function (v) {
12315            var out = new ArrayCtor(2);
12316            out[0] = v[0];
12317            out[1] = v[1];
12318            return out;
12319        },
12320        set: function (out, a, b) {
12321            out[0] = a;
12322            out[1] = b;
12323            return out;
12324        },
12325        add: function (out, v1, v2) {
12326            out[0] = v1[0] + v2[0];
12327            out[1] = v1[1] + v2[1];
12328            return out;
12329        },
12330        scaleAndAdd: function (out, v1, v2, a) {
12331            out[0] = v1[0] + v2[0] * a;
12332            out[1] = v1[1] + v2[1] * a;
12333            return out;
12334        },
12335        sub: function (out, v1, v2) {
12336            out[0] = v1[0] - v2[0];
12337            out[1] = v1[1] - v2[1];
12338            return out;
12339        },
12340        len: function (v) {
12341            return Math.sqrt(this.lenSquare(v));
12342        },
12343        lenSquare: function (v) {
12344            return v[0] * v[0] + v[1] * v[1];
12345        },
12346        mul: function (out, v1, v2) {
12347            out[0] = v1[0] * v2[0];
12348            out[1] = v1[1] * v2[1];
12349            return out;
12350        },
12351        div: function (out, v1, v2) {
12352            out[0] = v1[0] / v2[0];
12353            out[1] = v1[1] / v2[1];
12354            return out;
12355        },
12356        dot: function (v1, v2) {
12357            return v1[0] * v2[0] + v1[1] * v2[1];
12358        },
12359        scale: function (out, v, s) {
12360            out[0] = v[0] * s;
12361            out[1] = v[1] * s;
12362            return out;
12363        },
12364        normalize: function (out, v) {
12365            var d = vector.len(v);
12366            if (d === 0) {
12367                out[0] = 0;
12368                out[1] = 0;
12369            } else {
12370                out[0] = v[0] / d;
12371                out[1] = v[1] / d;
12372            }
12373            return out;
12374        },
12375        distance: function (v1, v2) {
12376            return Math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]));
12377        },
12378        distanceSquare: function (v1, v2) {
12379            return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]);
12380        },
12381        negate: function (out, v) {
12382            out[0] = -v[0];
12383            out[1] = -v[1];
12384            return out;
12385        },
12386        lerp: function (out, v1, v2, t) {
12387            out[0] = v1[0] + t * (v2[0] - v1[0]);
12388            out[1] = v1[1] + t * (v2[1] - v1[1]);
12389            return out;
12390        },
12391        applyTransform: function (out, v, m) {
12392            var x = v[0];
12393            var y = v[1];
12394            out[0] = m[0] * x + m[2] * y + m[4];
12395            out[1] = m[1] * x + m[3] * y + m[5];
12396            return out;
12397        },
12398        min: function (out, v1, v2) {
12399            out[0] = Math.min(v1[0], v2[0]);
12400            out[1] = Math.min(v1[1], v2[1]);
12401            return out;
12402        },
12403        max: function (out, v1, v2) {
12404            out[0] = Math.max(v1[0], v2[0]);
12405            out[1] = Math.max(v1[1], v2[1]);
12406            return out;
12407        }
12408    };
12409    vector.length = vector.len;
12410    vector.lengthSquare = vector.lenSquare;
12411    vector.dist = vector.distance;
12412    vector.distSquare = vector.distanceSquare;
12413    return vector;
12414});define('zrender/tool/matrix', [], function () {
12415    var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array;
12416    var matrix = {
12417        create: function () {
12418            var out = new ArrayCtor(6);
12419            matrix.identity(out);
12420            return out;
12421        },
12422        identity: function (out) {
12423            out[0] = 1;
12424            out[1] = 0;
12425            out[2] = 0;
12426            out[3] = 1;
12427            out[4] = 0;
12428            out[5] = 0;
12429            return out;
12430        },
12431        copy: function (out, m) {
12432            out[0] = m[0];
12433            out[1] = m[1];
12434            out[2] = m[2];
12435            out[3] = m[3];
12436            out[4] = m[4];
12437            out[5] = m[5];
12438            return out;
12439        },
12440        mul: function (out, m1, m2) {
12441            out[0] = m1[0] * m2[0] + m1[2] * m2[1];
12442            out[1] = m1[1] * m2[0] + m1[3] * m2[1];
12443            out[2] = m1[0] * m2[2] + m1[2] * m2[3];
12444            out[3] = m1[1] * m2[2] + m1[3] * m2[3];
12445            out[4] = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
12446            out[5] = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
12447            return out;
12448        },
12449        translate: function (out, a, v) {
12450            out[0] = a[0];
12451            out[1] = a[1];
12452            out[2] = a[2];
12453            out[3] = a[3];
12454            out[4] = a[4] + v[0];
12455            out[5] = a[5] + v[1];
12456            return out;
12457        },
12458        rotate: function (out, a, rad) {
12459            var aa = a[0];
12460            var ac = a[2];
12461            var atx = a[4];
12462            var ab = a[1];
12463            var ad = a[3];
12464            var aty = a[5];
12465            var st = Math.sin(rad);
12466            var ct = Math.cos(rad);
12467            out[0] = aa * ct + ab * st;
12468            out[1] = -aa * st + ab * ct;
12469            out[2] = ac * ct + ad * st;
12470            out[3] = -ac * st + ct * ad;
12471            out[4] = ct * atx + st * aty;
12472            out[5] = ct * aty - st * atx;
12473            return out;
12474        },
12475        scale: function (out, a, v) {
12476            var vx = v[0];
12477            var vy = v[1];
12478            out[0] = a[0] * vx;
12479            out[1] = a[1] * vy;
12480            out[2] = a[2] * vx;
12481            out[3] = a[3] * vy;
12482            out[4] = a[4] * vx;
12483            out[5] = a[5] * vy;
12484            return out;
12485        },
12486        invert: function (out, a) {
12487            var aa = a[0];
12488            var ac = a[2];
12489            var atx = a[4];
12490            var ab = a[1];
12491            var ad = a[3];
12492            var aty = a[5];
12493            var det = aa * ad - ab * ac;
12494            if (!det) {
12495                return null;
12496            }
12497            det = 1 / det;
12498            out[0] = ad * det;
12499            out[1] = -ab * det;
12500            out[2] = -ac * det;
12501            out[3] = aa * det;
12502            out[4] = (ac * aty - ad * atx) * det;
12503            out[5] = (ab * atx - aa * aty) * det;
12504            return out;
12505        }
12506    };
12507    return matrix;
12508});define('zrender/loadingEffect/Base', [
12509    'require',
12510    '../tool/util',
12511    '../shape/Text',
12512    '../shape/Rectangle'
12513], function (require) {
12514    var util = require('../tool/util');
12515    var TextShape = require('../shape/Text');
12516    var RectangleShape = require('../shape/Rectangle');
12517    var DEFAULT_TEXT = 'Loading...';
12518    var DEFAULT_TEXT_FONT = 'normal 16px Arial';
12519    function Base(options) {
12520        this.setOptions(options);
12521    }
12522    Base.prototype.createTextShape = function (textStyle) {
12523        return new TextShape({
12524            highlightStyle: util.merge({
12525                x: this.canvasWidth / 2,
12526                y: this.canvasHeight / 2,
12527                text: DEFAULT_TEXT,
12528                textAlign: 'center',
12529                textBaseline: 'middle',
12530                textFont: DEFAULT_TEXT_FONT,
12531                color: '#333',
12532                brushType: 'fill'
12533            }, textStyle, true)
12534        });
12535    };
12536    Base.prototype.createBackgroundShape = function (color) {
12537        return new RectangleShape({
12538            highlightStyle: {
12539                x: 0,
12540                y: 0,
12541                width: this.canvasWidth,
12542                height: this.canvasHeight,
12543                brushType: 'fill',
12544                color: color
12545            }
12546        });
12547    };
12548    Base.prototype.start = function (painter) {
12549        this.canvasWidth = painter._width;
12550        this.canvasHeight = painter._height;
12551        function addShapeHandle(param) {
12552            painter.storage.addHover(param);
12553        }
12554        function refreshHandle() {
12555            painter.refreshHover();
12556        }
12557        this.loadingTimer = this._start(addShapeHandle, refreshHandle);
12558    };
12559    Base.prototype._start = function () {
12560        return setInterval(function () {
12561        }, 10000);
12562    };
12563    Base.prototype.stop = function () {
12564        clearInterval(this.loadingTimer);
12565    };
12566    Base.prototype.setOptions = function (options) {
12567        this.options = options || {};
12568    };
12569    Base.prototype.adjust = function (value, region) {
12570        if (value <= region[0]) {
12571            value = region[0];
12572        } else if (value >= region[1]) {
12573            value = region[1];
12574        }
12575        return value;
12576    };
12577    Base.prototype.getLocation = function (loc, totalWidth, totalHeight) {
12578        var x = loc.x != null ? loc.x : 'center';
12579        switch (x) {
12580        case 'center':
12581            x = Math.floor((this.canvasWidth - totalWidth) / 2);
12582            break;
12583        case 'left':
12584            x = 0;
12585            break;
12586        case 'right':
12587            x = this.canvasWidth - totalWidth;
12588            break;
12589        }
12590        var y = loc.y != null ? loc.y : 'center';
12591        switch (y) {
12592        case 'center':
12593            y = Math.floor((this.canvasHeight - totalHeight) / 2);
12594            break;
12595        case 'top':
12596            y = 0;
12597            break;
12598        case 'bottom':
12599            y = this.canvasHeight - totalHeight;
12600            break;
12601        }
12602        return {
12603            x: x,
12604            y: y,
12605            width: totalWidth,
12606            height: totalHeight
12607        };
12608    };
12609    return Base;
12610});define('zrender/Layer', [
12611    'require',
12612    './mixin/Transformable',
12613    './tool/util',
12614    './config'
12615], function (require) {
12616    var Transformable = require('./mixin/Transformable');
12617    var util = require('./tool/util');
12618    var vmlCanvasManager = window['G_vmlCanvasManager'];
12619    var config = require('./config');
12620    function returnFalse() {
12621        return false;
12622    }
12623    function createDom(id, type, painter) {
12624        var newDom = document.createElement(type);
12625        var width = painter.getWidth();
12626        var height = painter.getHeight();
12627        newDom.style.position = 'absolute';
12628        newDom.style.left = 0;
12629        newDom.style.top = 0;
12630        newDom.style.width = width + 'px';
12631        newDom.style.height = height + 'px';
12632        newDom.width = width * config.devicePixelRatio;
12633        newDom.height = height * config.devicePixelRatio;
12634        newDom.setAttribute('data-zr-dom-id', id);
12635        return newDom;
12636    }
12637    var Layer = function (id, painter) {
12638        this.id = id;
12639        this.dom = createDom(id, 'canvas', painter);
12640        this.dom.onselectstart = returnFalse;
12641        this.dom.style['-webkit-user-select'] = 'none';
12642        this.dom.style['user-select'] = 'none';
12643        this.dom.style['-webkit-touch-callout'] = 'none';
12644        this.dom.style['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
12645        this.dom.className = config.elementClassName;
12646        vmlCanvasManager && vmlCanvasManager.initElement(this.dom);
12647        this.domBack = null;
12648        this.ctxBack = null;
12649        this.painter = painter;
12650        this.unusedCount = 0;
12651        this.config = null;
12652        this.dirty = true;
12653        this.elCount = 0;
12654        this.clearColor = 0;
12655        this.motionBlur = false;
12656        this.lastFrameAlpha = 0.7;
12657        this.zoomable = false;
12658        this.panable = false;
12659        this.maxZoom = Infinity;
12660        this.minZoom = 0;
12661        Transformable.call(this);
12662    };
12663    Layer.prototype.initContext = function () {
12664        this.ctx = this.dom.getContext('2d');
12665        var dpr = config.devicePixelRatio;
12666        if (dpr != 1) {
12667            this.ctx.scale(dpr, dpr);
12668        }
12669    };
12670    Layer.prototype.createBackBuffer = function () {
12671        if (vmlCanvasManager) {
12672            return;
12673        }
12674        this.domBack = createDom('back-' + this.id, 'canvas', this.painter);
12675        this.ctxBack = this.domBack.getContext('2d');
12676        var dpr = config.devicePixelRatio;
12677        if (dpr != 1) {
12678            this.ctxBack.scale(dpr, dpr);
12679        }
12680    };
12681    Layer.prototype.resize = function (width, height) {
12682        var dpr = config.devicePixelRatio;
12683        this.dom.style.width = width + 'px';
12684        this.dom.style.height = height + 'px';
12685        this.dom.setAttribute('width', width * dpr);
12686        this.dom.setAttribute('height', height * dpr);
12687        if (dpr != 1) {
12688            this.ctx.scale(dpr, dpr);
12689        }
12690        if (this.domBack) {
12691            this.domBack.setAttribute('width', width * dpr);
12692            this.domBack.setAttribute('height', height * dpr);
12693            if (dpr != 1) {
12694                this.ctxBack.scale(dpr, dpr);
12695            }
12696        }
12697    };
12698    Layer.prototype.clear = function () {
12699        var dom = this.dom;
12700        var ctx = this.ctx;
12701        var width = dom.width;
12702        var height = dom.height;
12703        var haveClearColor = this.clearColor && !vmlCanvasManager;
12704        var haveMotionBLur = this.motionBlur && !vmlCanvasManager;
12705        var lastFrameAlpha = this.lastFrameAlpha;
12706        var dpr = config.devicePixelRatio;
12707        if (haveMotionBLur) {
12708            if (!this.domBack) {
12709                this.createBackBuffer();
12710            }
12711            this.ctxBack.globalCompositeOperation = 'copy';
12712            this.ctxBack.drawImage(dom, 0, 0, width / dpr, height / dpr);
12713        }
12714        ctx.clearRect(0, 0, width / dpr, height / dpr);
12715        if (haveClearColor) {
12716            ctx.save();
12717            ctx.fillStyle = this.clearColor;
12718            ctx.fillRect(0, 0, width / dpr, height / dpr);
12719            ctx.restore();
12720        }
12721        if (haveMotionBLur) {
12722            var domBack = this.domBack;
12723            ctx.save();
12724            ctx.globalAlpha = lastFrameAlpha;
12725            ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr);
12726            ctx.restore();
12727        }
12728    };
12729    util.merge(Layer.prototype, Transformable.prototype);
12730    return Layer;
12731});define('zrender/shape/Text', [
12732    'require',
12733    '../tool/area',
12734    './Base',
12735    '../tool/util'
12736], function (require) {
12737    var area = require('../tool/area');
12738    var Base = require('./Base');
12739    var Text = function (options) {
12740        Base.call(this, options);
12741    };
12742    Text.prototype = {
12743        type: 'text',
12744        brush: function (ctx, isHighlight) {
12745            var style = this.style;
12746            if (isHighlight) {
12747                style = this.getHighlightStyle(style, this.highlightStyle || {});
12748            }
12749            if (typeof style.text == 'undefined' || style.text === false) {
12750                return;
12751            }
12752            ctx.save();
12753            this.doClip(ctx);
12754            this.setContext(ctx, style);
12755            this.setTransform(ctx);
12756            if (style.textFont) {
12757                ctx.font = style.textFont;
12758            }
12759            ctx.textAlign = style.textAlign || 'start';
12760            ctx.textBaseline = style.textBaseline || 'middle';
12761            var text = (style.text + '').split('\n');
12762            var lineHeight = area.getTextHeight('国', style.textFont);
12763            var rect = this.getRect(style);
12764            var x = style.x;
12765            var y;
12766            if (style.textBaseline == 'top') {
12767                y = rect.y;
12768            } else if (style.textBaseline == 'bottom') {
12769                y = rect.y + lineHeight;
12770            } else {
12771                y = rect.y + lineHeight / 2;
12772            }
12773            for (var i = 0, l = text.length; i < l; i++) {
12774                if (style.maxWidth) {
12775                    switch (style.brushType) {
12776                    case 'fill':
12777                        ctx.fillText(text[i], x, y, style.maxWidth);
12778                        break;
12779                    case 'stroke':
12780                        ctx.strokeText(text[i], x, y, style.maxWidth);
12781                        break;
12782                    case 'both':
12783                        ctx.fillText(text[i], x, y, style.maxWidth);
12784                        ctx.strokeText(text[i], x, y, style.maxWidth);
12785                        break;
12786                    default:
12787                        ctx.fillText(text[i], x, y, style.maxWidth);
12788                    }
12789                } else {
12790                    switch (style.brushType) {
12791                    case 'fill':
12792                        ctx.fillText(text[i], x, y);
12793                        break;
12794                    case 'stroke':
12795                        ctx.strokeText(text[i], x, y);
12796                        break;
12797                    case 'both':
12798                        ctx.fillText(text[i], x, y);
12799                        ctx.strokeText(text[i], x, y);
12800                        break;
12801                    default:
12802                        ctx.fillText(text[i], x, y);
12803                    }
12804                }
12805                y += lineHeight;
12806            }
12807            ctx.restore();
12808            return;
12809        },
12810        getRect: function (style) {
12811            if (style.__rect) {
12812                return style.__rect;
12813            }
12814            var width = area.getTextWidth(style.text, style.textFont);
12815            var height = area.getTextHeight(style.text, style.textFont);
12816            var textX = style.x;
12817            if (style.textAlign == 'end' || style.textAlign == 'right') {
12818                textX -= width;
12819            } else if (style.textAlign == 'center') {
12820                textX -= width / 2;
12821            }
12822            var textY;
12823            if (style.textBaseline == 'top') {
12824                textY = style.y;
12825            } else if (style.textBaseline == 'bottom') {
12826                textY = style.y - height;
12827            } else {
12828                textY = style.y - height / 2;
12829            }
12830            style.__rect = {
12831                x: textX,
12832                y: textY,
12833                width: width,
12834                height: height
12835            };
12836            return style.__rect;
12837        }
12838    };
12839    require('../tool/util').inherits(Text, Base);
12840    return Text;
12841});define('zrender/shape/Rectangle', [
12842    'require',
12843    './Base',
12844    '../tool/util'
12845], function (require) {
12846    var Base = require('./Base');
12847    var Rectangle = function (options) {
12848        Base.call(this, options);
12849    };
12850    Rectangle.prototype = {
12851        type: 'rectangle',
12852        _buildRadiusPath: function (ctx, style) {
12853            var x = style.x;
12854            var y = style.y;
12855            var width = style.width;
12856            var height = style.height;
12857            var r = style.radius;
12858            var r1;
12859            var r2;
12860            var r3;
12861            var r4;
12862            if (typeof r === 'number') {
12863                r1 = r2 = r3 = r4 = r;
12864            } else if (r instanceof Array) {
12865                if (r.length === 1) {
12866                    r1 = r2 = r3 = r4 = r[0];
12867                } else if (r.length === 2) {
12868                    r1 = r3 = r[0];
12869                    r2 = r4 = r[1];
12870                } else if (r.length === 3) {
12871                    r1 = r[0];
12872                    r2 = r4 = r[1];
12873                    r3 = r[2];
12874                } else {
12875                    r1 = r[0];
12876                    r2 = r[1];
12877                    r3 = r[2];
12878                    r4 = r[3];
12879                }
12880            } else {
12881                r1 = r2 = r3 = r4 = 0;
12882            }
12883            var total;
12884            if (r1 + r2 > width) {
12885                total = r1 + r2;
12886                r1 *= width / total;
12887                r2 *= width / total;
12888            }
12889            if (r3 + r4 > width) {
12890                total = r3 + r4;
12891                r3 *= width / total;
12892                r4 *= width / total;
12893            }
12894            if (r2 + r3 > height) {
12895                total = r2 + r3;
12896                r2 *= height / total;
12897                r3 *= height / total;
12898            }
12899            if (r1 + r4 > height) {
12900                total = r1 + r4;
12901                r1 *= height / total;
12902                r4 *= height / total;
12903            }
12904            ctx.moveTo(x + r1, y);
12905            ctx.lineTo(x + width - r2, y);
12906            r2 !== 0 && ctx.quadraticCurveTo(x + width, y, x + width, y + r2);
12907            ctx.lineTo(x + width, y + height - r3);
12908            r3 !== 0 && ctx.quadraticCurveTo(x + width, y + height, x + width - r3, y + height);
12909            ctx.lineTo(x + r4, y + height);
12910            r4 !== 0 && ctx.quadraticCurveTo(x, y + height, x, y + height - r4);
12911            ctx.lineTo(x, y + r1);
12912            r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
12913        },
12914        buildPath: function (ctx, style) {
12915            if (!style.radius) {
12916                ctx.moveTo(style.x, style.y);
12917                ctx.lineTo(style.x + style.width, style.y);
12918                ctx.lineTo(style.x + style.width, style.y + style.height);
12919                ctx.lineTo(style.x, style.y + style.height);
12920                ctx.lineTo(style.x, style.y);
12921            } else {
12922                this._buildRadiusPath(ctx, style);
12923            }
12924            ctx.closePath();
12925            return;
12926        },
12927        getRect: function (style) {
12928            if (style.__rect) {
12929                return style.__rect;
12930            }
12931            var lineWidth;
12932            if (style.brushType == 'stroke' || style.brushType == 'fill') {
12933                lineWidth = style.lineWidth || 1;
12934            } else {
12935                lineWidth = 0;
12936            }
12937            style.__rect = {
12938                x: Math.round(style.x - lineWidth / 2),
12939                y: Math.round(style.y - lineWidth / 2),
12940                width: style.width + lineWidth,
12941                height: style.height + lineWidth
12942            };
12943            return style.__rect;
12944        }
12945    };
12946    require('../tool/util').inherits(Rectangle, Base);
12947    return Rectangle;
12948});define('zrender/tool/area', [
12949    'require',
12950    './util',
12951    './curve'
12952], function (require) {
12953    'use strict';
12954    var util = require('./util');
12955    var curve = require('./curve');
12956    var _ctx;
12957    var _textWidthCache = {};
12958    var _textHeightCache = {};
12959    var _textWidthCacheCounter = 0;
12960    var _textHeightCacheCounter = 0;
12961    var TEXT_CACHE_MAX = 5000;
12962    var PI2 = Math.PI * 2;
12963    function normalizeRadian(angle) {
12964        angle %= PI2;
12965        if (angle < 0) {
12966            angle += PI2;
12967        }
12968        return angle;
12969    }
12970    function isInside(shape, area, x, y) {
12971        if (!area || !shape) {
12972            return false;
12973        }
12974        var zoneType = shape.type;
12975        _ctx = _ctx || util.getContext();
12976        var _mathReturn = _mathMethod(shape, area, x, y);
12977        if (typeof _mathReturn != 'undefined') {
12978            return _mathReturn;
12979        }
12980        if (shape.buildPath && _ctx.isPointInPath) {
12981            return _buildPathMethod(shape, _ctx, area, x, y);
12982        }
12983        switch (zoneType) {
12984        case 'ellipse':
12985            return true;
12986        case 'trochoid':
12987            var _r = area.location == 'out' ? area.r1 + area.r2 + area.d : area.r1 - area.r2 + area.d;
12988            return isInsideCircle(area, x, y, _r);
12989        case 'rose':
12990            return isInsideCircle(area, x, y, area.maxr);
12991        default:
12992            return false;
12993        }
12994    }
12995    function _mathMethod(shape, area, x, y) {
12996        var zoneType = shape.type;
12997        switch (zoneType) {
12998        case 'bezier-curve':
12999            if (typeof area.cpX2 === 'undefined') {
13000                return isInsideQuadraticStroke(area.xStart, area.yStart, area.cpX1, area.cpY1, area.xEnd, area.yEnd, area.lineWidth, x, y);
13001            }
13002            return isInsideCubicStroke(area.xStart, area.yStart, area.cpX1, area.cpY1, area.cpX2, area.cpY2, area.xEnd, area.yEnd, area.lineWidth, x, y);
13003        case 'line':
13004            return isInsideLine(area.xStart, area.yStart, area.xEnd, area.yEnd, area.lineWidth, x, y);
13005        case 'polyline':
13006            return isInsidePolyline(area.pointList, area.lineWidth, x, y);
13007        case 'ring':
13008            return isInsideRing(area.x, area.y, area.r0, area.r, x, y);
13009        case 'circle':
13010            return isInsideCircle(area.x, area.y, area.r, x, y);
13011        case 'sector':
13012            var startAngle = area.startAngle * Math.PI / 180;
13013            var endAngle = area.endAngle * Math.PI / 180;
13014            if (!area.clockWise) {
13015                startAngle = -startAngle;
13016                endAngle = -endAngle;
13017            }
13018            return isInsideSector(area.x, area.y, area.r0, area.r, startAngle, endAngle, !area.clockWise, x, y);
13019        case 'path':
13020            return area.pathArray && isInsidePath(area.pathArray, Math.max(area.lineWidth, 5), area.brushType, x, y);
13021        case 'polygon':
13022        case 'star':
13023        case 'isogon':
13024            return isInsidePolygon(area.pointList, x, y);
13025        case 'text':
13026            var rect = area.__rect || shape.getRect(area);
13027            return isInsideRect(rect.x, rect.y, rect.width, rect.height, x, y);
13028        case 'rectangle':
13029        case 'image':
13030            return isInsideRect(area.x, area.y, area.width, area.height, x, y);
13031        }
13032    }
13033    function _buildPathMethod(shape, context, area, x, y) {
13034        context.beginPath();
13035        shape.buildPath(context, area);
13036        context.closePath();
13037        return context.isPointInPath(x, y);
13038    }
13039    function isOutside(shape, area, x, y) {
13040        return !isInside(shape, area, x, y);
13041    }
13042    function isInsideLine(x0, y0, x1, y1, lineWidth, x, y) {
13043        if (lineWidth === 0) {
13044            return false;
13045        }
13046        var _l = Math.max(lineWidth, 5);
13047        var _a = 0;
13048        var _b = x0;
13049        if (y > y0 + _l && y > y1 + _l || y < y0 - _l && y < y1 - _l || x > x0 + _l && x > x1 + _l || x < x0 - _l && x < x1 - _l) {
13050            return false;
13051        }
13052        if (x0 !== x1) {
13053            _a = (y0 - y1) / (x0 - x1);
13054            _b = (x0 * y1 - x1 * y0) / (x0 - x1);
13055        } else {
13056            return Math.abs(x - x0) <= _l / 2;
13057        }
13058        var tmp = _a * x - y + _b;
13059        var _s = tmp * tmp / (_a * _a + 1);
13060        return _s <= _l / 2 * _l / 2;
13061    }
13062    function isInsideCubicStroke(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
13063        if (lineWidth === 0) {
13064            return false;
13065        }
13066        var _l = Math.max(lineWidth, 5);
13067        if (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l) {
13068            return false;
13069        }
13070        var d = curve.cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, null);
13071        return d <= _l / 2;
13072    }
13073    function isInsideQuadraticStroke(x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
13074        if (lineWidth === 0) {
13075            return false;
13076        }
13077        var _l = Math.max(lineWidth, 5);
13078        if (y > y0 + _l && y > y1 + _l && y > y2 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l) {
13079            return false;
13080        }
13081        var d = curve.quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, null);
13082        return d <= _l / 2;
13083    }
13084    function isInsideArcStroke(cx, cy, r, startAngle, endAngle, anticlockwise, lineWidth, x, y) {
13085        if (lineWidth === 0) {
13086            return false;
13087        }
13088        var _l = Math.max(lineWidth, 5);
13089        x -= cx;
13090        y -= cy;
13091        var d = Math.sqrt(x * x + y * y);
13092        if (d - _l > r || d + _l < r) {
13093            return false;
13094        }
13095        if (Math.abs(startAngle - endAngle) >= PI2) {
13096            return true;
13097        }
13098        if (anticlockwise) {
13099            var tmp = startAngle;
13100            startAngle = normalizeRadian(endAngle);
13101            endAngle = normalizeRadian(tmp);
13102        } else {
13103            startAngle = normalizeRadian(startAngle);
13104            endAngle = normalizeRadian(endAngle);
13105        }
13106        if (startAngle > endAngle) {
13107            endAngle += PI2;
13108        }
13109        var angle = Math.atan2(y, x);
13110        if (angle < 0) {
13111            angle += PI2;
13112        }
13113        return angle >= startAngle && angle <= endAngle || angle + PI2 >= startAngle && angle + PI2 <= endAngle;
13114    }
13115    function isInsidePolyline(points, lineWidth, x, y) {
13116        var lineWidth = Math.max(lineWidth, 10);
13117        for (var i = 0, l = points.length - 1; i < l; i++) {
13118            var x0 = points[i][0];
13119            var y0 = points[i][1];
13120            var x1 = points[i + 1][0];
13121            var y1 = points[i + 1][1];
13122            if (isInsideLine(x0, y0, x1, y1, lineWidth, x, y)) {
13123                return true;
13124            }
13125        }
13126        return false;
13127    }
13128    function isInsideRing(cx, cy, r0, r, x, y) {
13129        var d = (x - cx) * (x - cx) + (y - cy) * (y - cy);
13130        return d < r * r && d > r0 * r0;
13131    }
13132    function isInsideRect(x0, y0, width, height, x, y) {
13133        return x >= x0 && x <= x0 + width && y >= y0 && y <= y0 + height;
13134    }
13135    function isInsideCircle(x0, y0, r, x, y) {
13136        return (x - x0) * (x - x0) + (y - y0) * (y - y0) < r * r;
13137    }
13138    function isInsideSector(cx, cy, r0, r, startAngle, endAngle, anticlockwise, x, y) {
13139        return isInsideArcStroke(cx, cy, (r0 + r) / 2, startAngle, endAngle, anticlockwise, r - r0, x, y);
13140    }
13141    function isInsidePolygon(points, x, y) {
13142        var N = points.length;
13143        var w = 0;
13144        for (var i = 0, j = N - 1; i < N; i++) {
13145            var x0 = points[j][0];
13146            var y0 = points[j][1];
13147            var x1 = points[i][0];
13148            var y1 = points[i][1];
13149            w += windingLine(x0, y0, x1, y1, x, y);
13150            j = i;
13151        }
13152        return w !== 0;
13153    }
13154    function windingLine(x0, y0, x1, y1, x, y) {
13155        if (y > y0 && y > y1 || y < y0 && y < y1) {
13156            return 0;
13157        }
13158        if (y1 == y0) {
13159            return 0;
13160        }
13161        var dir = y1 < y0 ? 1 : -1;
13162        var t = (y - y0) / (y1 - y0);
13163        var x_ = t * (x1 - x0) + x0;
13164        return x_ > x ? dir : 0;
13165    }
13166    var roots = [
13167        -1,
13168        -1,
13169        -1
13170    ];
13171    var extrema = [
13172        -1,
13173        -1
13174    ];
13175    function swapExtrema() {
13176        var tmp = extrema[0];
13177        extrema[0] = extrema[1];
13178        extrema[1] = tmp;
13179    }
13180    function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
13181        if (y > y0 && y > y1 && y > y2 && y > y3 || y < y0 && y < y1 && y < y2 && y < y3) {
13182            return 0;
13183        }
13184        var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
13185        if (nRoots === 0) {
13186            return 0;
13187        } else {
13188            var w = 0;
13189            var nExtrema = -1;
13190            var y0_, y1_;
13191            for (var i = 0; i < nRoots; i++) {
13192                var t = roots[i];
13193                var x_ = curve.cubicAt(x0, x1, x2, x3, t);
13194                if (x_ < x) {
13195                    continue;
13196                }
13197                if (nExtrema < 0) {
13198                    nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
13199                    if (extrema[1] < extrema[0] && nExtrema > 1) {
13200                        swapExtrema();
13201                    }
13202                    y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
13203                    if (nExtrema > 1) {
13204                        y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
13205                    }
13206                }
13207                if (nExtrema == 2) {
13208                    if (t < extrema[0]) {
13209                        w += y0_ < y0 ? 1 : -1;
13210                    } else if (t < extrema[1]) {
13211                        w += y1_ < y0_ ? 1 : -1;
13212                    } else {
13213                        w += y3 < y1_ ? 1 : -1;
13214                    }
13215                } else {
13216                    if (t < extrema[0]) {
13217                        w += y0_ < y0 ? 1 : -1;
13218                    } else {
13219                        w += y3 < y0_ ? 1 : -1;
13220                    }
13221                }
13222            }
13223            return w;
13224        }
13225    }
13226    function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
13227        if (y > y0 && y > y1 && y > y2 || y < y0 && y < y1 && y < y2) {
13228            return 0;
13229        }
13230        var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
13231        if (nRoots === 0) {
13232            return 0;
13233        } else {
13234            var t = curve.quadraticExtremum(y0, y1, y2);
13235            if (t >= 0 && t <= 1) {
13236                var w = 0;
13237                var y_ = curve.quadraticAt(y0, y1, y2, t);
13238                for (var i = 0; i < nRoots; i++) {
13239                    var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
13240                    if (x_ < x) {
13241                        continue;
13242                    }
13243                    if (roots[i] < t) {
13244                        w += y_ < y0 ? 1 : -1;
13245                    } else {
13246                        w += y2 < y_ ? 1 : -1;
13247                    }
13248                }
13249                return w;
13250            } else {
13251                var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
13252                if (x_ < x) {
13253                    return 0;
13254                }
13255                return y2 < y0 ? 1 : -1;
13256            }
13257        }
13258    }
13259    function windingArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y) {
13260        y -= cy;
13261        if (y > r || y < -r) {
13262            return 0;
13263        }
13264        var tmp = Math.sqrt(r * r - y * y);
13265        roots[0] = -tmp;
13266        roots[1] = tmp;
13267        if (Math.abs(startAngle - endAngle) >= PI2) {
13268            startAngle = 0;
13269            endAngle = PI2;
13270            var dir = anticlockwise ? 1 : -1;
13271            if (x >= roots[0] + cx && x <= roots[1] + cx) {
13272                return dir;
13273            } else {
13274                return 0;
13275            }
13276        }
13277        if (anticlockwise) {
13278            var tmp = startAngle;
13279            startAngle = normalizeRadian(endAngle);
13280            endAngle = normalizeRadian(tmp);
13281        } else {
13282            startAngle = normalizeRadian(startAngle);
13283            endAngle = normalizeRadian(endAngle);
13284        }
13285        if (startAngle > endAngle) {
13286            endAngle += PI2;
13287        }
13288        var w = 0;
13289        for (var i = 0; i < 2; i++) {
13290            var x_ = roots[i];
13291            if (x_ + cx > x) {
13292                var angle = Math.atan2(y, x_);
13293                var dir = anticlockwise ? 1 : -1;
13294                if (angle < 0) {
13295                    angle = PI2 + angle;
13296                }
13297                if (angle >= startAngle && angle <= endAngle || angle + PI2 >= startAngle && angle + PI2 <= endAngle) {
13298                    if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
13299                        dir = -dir;
13300                    }
13301                    w += dir;
13302                }
13303            }
13304        }
13305        return w;
13306    }
13307    function isInsidePath(pathArray, lineWidth, brushType, x, y) {
13308        var w = 0;
13309        var xi = 0;
13310        var yi = 0;
13311        var x0 = 0;
13312        var y0 = 0;
13313        var beginSubpath = true;
13314        var firstCmd = true;
13315        brushType = brushType || 'fill';
13316        var hasStroke = brushType === 'stroke' || brushType === 'both';
13317        var hasFill = brushType === 'fill' || brushType === 'both';
13318        for (var i = 0; i < pathArray.length; i++) {
13319            var seg = pathArray[i];
13320            var p = seg.points;
13321            if (beginSubpath || seg.command === 'M') {
13322                if (i > 0) {
13323                    if (hasFill) {
13324                        w += windingLine(xi, yi, x0, y0, x, y);
13325                    }
13326                    if (w !== 0) {
13327                        return true;
13328                    }
13329                }
13330                x0 = p[p.length - 2];
13331                y0 = p[p.length - 1];
13332                beginSubpath = false;
13333                if (firstCmd && seg.command !== 'A') {
13334                    firstCmd = false;
13335                    xi = x0;
13336                    yi = y0;
13337                }
13338            }
13339            switch (seg.command) {
13340            case 'M':
13341                xi = p[0];
13342                yi = p[1];
13343                break;
13344            case 'L':
13345                if (hasStroke) {
13346                    if (isInsideLine(xi, yi, p[0], p[1], lineWidth, x, y)) {
13347                        return true;
13348                    }
13349                }
13350                if (hasFill) {
13351                    w += windingLine(xi, yi, p[0], p[1], x, y);
13352                }
13353                xi = p[0];
13354                yi = p[1];
13355                break;
13356            case 'C':
13357                if (hasStroke) {
13358                    if (isInsideCubicStroke(xi, yi, p[0], p[1], p[2], p[3], p[4], p[5], lineWidth, x, y)) {
13359                        return true;
13360                    }
13361                }
13362                if (hasFill) {
13363                    w += windingCubic(xi, yi, p[0], p[1], p[2], p[3], p[4], p[5], x, y);
13364                }
13365                xi = p[4];
13366                yi = p[5];
13367                break;
13368            case 'Q':
13369                if (hasStroke) {
13370                    if (isInsideQuadraticStroke(xi, yi, p[0], p[1], p[2], p[3], lineWidth, x, y)) {
13371                        return true;
13372                    }
13373                }
13374                if (hasFill) {
13375                    w += windingQuadratic(xi, yi, p[0], p[1], p[2], p[3], x, y);
13376                }
13377                xi = p[2];
13378                yi = p[3];
13379                break;
13380            case 'A':
13381                var cx = p[0];
13382                var cy = p[1];
13383                var rx = p[2];
13384                var ry = p[3];
13385                var theta = p[4];
13386                var dTheta = p[5];
13387                var x1 = Math.cos(theta) * rx + cx;
13388                var y1 = Math.sin(theta) * ry + cy;
13389                if (!firstCmd) {
13390                    w += windingLine(xi, yi, x1, y1);
13391                } else {
13392                    firstCmd = false;
13393                    x0 = x1;
13394                    y0 = y1;
13395                }
13396                var _x = (x - cx) * ry / rx + cx;
13397                if (hasStroke) {
13398                    if (isInsideArcStroke(cx, cy, ry, theta, theta + dTheta, 1 - p[7], lineWidth, _x, y)) {
13399                        return true;
13400                    }
13401                }
13402                if (hasFill) {
13403                    w += windingArc(cx, cy, ry, theta, theta + dTheta, 1 - p[7], _x, y);
13404                }
13405                xi = Math.cos(theta + dTheta) * rx + cx;
13406                yi = Math.sin(theta + dTheta) * ry + cy;
13407                break;
13408            case 'z':
13409                if (hasStroke) {
13410                    if (isInsideLine(xi, yi, x0, y0, lineWidth, x, y)) {
13411                        return true;
13412                    }
13413                }
13414                beginSubpath = true;
13415                break;
13416            }
13417        }
13418        if (hasFill) {
13419            w += windingLine(xi, yi, x0, y0, x, y);
13420        }
13421        return w !== 0;
13422    }
13423    function getTextWidth(text, textFont) {
13424        var key = text + ':' + textFont;
13425        if (_textWidthCache[key]) {
13426            return _textWidthCache[key];
13427        }
13428        _ctx = _ctx || util.getContext();
13429        _ctx.save();
13430        if (textFont) {
13431            _ctx.font = textFont;
13432        }
13433        text = (text + '').split('\n');
13434        var width = 0;
13435        for (var i = 0, l = text.length; i < l; i++) {
13436            width = Math.max(_ctx.measureText(text[i]).width, width);
13437        }
13438        _ctx.restore();
13439        _textWidthCache[key] = width;
13440        if (++_textWidthCacheCounter > TEXT_CACHE_MAX) {
13441            _textWidthCacheCounter = 0;
13442            _textWidthCache = {};
13443        }
13444        return width;
13445    }
13446    function getTextHeight(text, textFont) {
13447        var key = text + ':' + textFont;
13448        if (_textHeightCache[key]) {
13449            return _textHeightCache[key];
13450        }
13451        _ctx = _ctx || util.getContext();
13452        _ctx.save();
13453        if (textFont) {
13454            _ctx.font = textFont;
13455        }
13456        text = (text + '').split('\n');
13457        var height = (_ctx.measureText('国').width + 2) * text.length;
13458        _ctx.restore();
13459        _textHeightCache[key] = height;
13460        if (++_textHeightCacheCounter > TEXT_CACHE_MAX) {
13461            _textHeightCacheCounter = 0;
13462            _textHeightCache = {};
13463        }
13464        return height;
13465    }
13466    return {
13467        isInside: isInside,
13468        isOutside: isOutside,
13469        getTextWidth: getTextWidth,
13470        getTextHeight: getTextHeight,
13471        isInsidePath: isInsidePath,
13472        isInsidePolygon: isInsidePolygon,
13473        isInsideSector: isInsideSector,
13474        isInsideCircle: isInsideCircle,
13475        isInsideLine: isInsideLine,
13476        isInsideRect: isInsideRect,
13477        isInsidePolyline: isInsidePolyline,
13478        isInsideCubicStroke: isInsideCubicStroke,
13479        isInsideQuadraticStroke: isInsideQuadraticStroke
13480    };
13481});define('zrender/shape/Base', [
13482    'require',
13483    '../tool/matrix',
13484    '../tool/guid',
13485    '../tool/util',
13486    '../tool/log',
13487    '../mixin/Transformable',
13488    '../mixin/Eventful',
13489    '../tool/area',
13490    '../tool/color'
13491], function (require) {
13492    var vmlCanvasManager = window['G_vmlCanvasManager'];
13493    var matrix = require('../tool/matrix');
13494    var guid = require('../tool/guid');
13495    var util = require('../tool/util');
13496    var log = require('../tool/log');
13497    var Transformable = require('../mixin/Transformable');
13498    var Eventful = require('../mixin/Eventful');
13499    function _fillText(ctx, text, x, y, textFont, textAlign, textBaseline) {
13500        if (textFont) {
13501            ctx.font = textFont;
13502        }
13503        ctx.textAlign = textAlign;
13504        ctx.textBaseline = textBaseline;
13505        var rect = _getTextRect(text, x, y, textFont, textAlign, textBaseline);
13506        text = (text + '').split('\n');
13507        var lineHeight = require('../tool/area').getTextHeight('国', textFont);
13508        switch (textBaseline) {
13509        case 'top':
13510            y = rect.y;
13511            break;
13512        case 'bottom':
13513            y = rect.y + lineHeight;
13514            break;
13515        default:
13516            y = rect.y + lineHeight / 2;
13517        }
13518        for (var i = 0, l = text.length; i < l; i++) {
13519            ctx.fillText(text[i], x, y);
13520            y += lineHeight;
13521        }
13522    }
13523    function _getTextRect(text, x, y, textFont, textAlign, textBaseline) {
13524        var area = require('../tool/area');
13525        var width = area.getTextWidth(text, textFont);
13526        var lineHeight = area.getTextHeight('国', textFont);
13527        text = (text + '').split('\n');
13528        switch (textAlign) {
13529        case 'end':
13530        case 'right':
13531            x -= width;
13532            break;
13533        case 'center':
13534            x -= width / 2;
13535            break;
13536        }
13537        switch (textBaseline) {
13538        case 'top':
13539            break;
13540        case 'bottom':
13541            y -= lineHeight * text.length;
13542            break;
13543        default:
13544            y -= lineHeight * text.length / 2;
13545        }
13546        return {
13547            x: x,
13548            y: y,
13549            width: width,
13550            height: lineHeight * text.length
13551        };
13552    }
13553    var Base = function (options) {
13554        options = options || {};
13555        this.id = options.id || guid();
13556        for (var key in options) {
13557            this[key] = options[key];
13558        }
13559        this.style = this.style || {};
13560        this.highlightStyle = this.highlightStyle || null;
13561        this.parent = null;
13562        this.__dirty = true;
13563        this.__clipShapes = [];
13564        Transformable.call(this);
13565        Eventful.call(this);
13566    };
13567    Base.prototype.invisible = false;
13568    Base.prototype.ignore = false;
13569    Base.prototype.zlevel = 0;
13570    Base.prototype.draggable = false;
13571    Base.prototype.clickable = false;
13572    Base.prototype.hoverable = true;
13573    Base.prototype.z = 0;
13574    Base.prototype.brush = function (ctx, isHighlight) {
13575        var style = this.beforeBrush(ctx, isHighlight);
13576        ctx.beginPath();
13577        this.buildPath(ctx, style);
13578        switch (style.brushType) {
13579        case 'both':
13580            ctx.fill();
13581        case 'stroke':
13582            style.lineWidth > 0 && ctx.stroke();
13583            break;
13584        default:
13585            ctx.fill();
13586        }
13587        this.drawText(ctx, style, this.style);
13588        this.afterBrush(ctx);
13589    };
13590    Base.prototype.beforeBrush = function (ctx, isHighlight) {
13591        var style = this.style;
13592        if (this.brushTypeOnly) {
13593            style.brushType = this.brushTypeOnly;
13594        }
13595        if (isHighlight) {
13596            style = this.getHighlightStyle(style, this.highlightStyle || {}, this.brushTypeOnly);
13597        }
13598        if (this.brushTypeOnly == 'stroke') {
13599            style.strokeColor = style.strokeColor || style.color;
13600        }
13601        ctx.save();
13602        this.doClip(ctx);
13603        this.setContext(ctx, style);
13604        this.setTransform(ctx);
13605        return style;
13606    };
13607    Base.prototype.afterBrush = function (ctx) {
13608        ctx.restore();
13609    };
13610    var STYLE_CTX_MAP = [
13611        [
13612            'color',
13613            'fillStyle'
13614        ],
13615        [
13616            'strokeColor',
13617            'strokeStyle'
13618        ],
13619        [
13620            'opacity',
13621            'globalAlpha'
13622        ],
13623        [
13624            'lineCap',
13625            'lineCap'
13626        ],
13627        [
13628            'lineJoin',
13629            'lineJoin'
13630        ],
13631        [
13632            'miterLimit',
13633            'miterLimit'
13634        ],
13635        [
13636            'lineWidth',
13637            'lineWidth'
13638        ],
13639        [
13640            'shadowBlur',
13641            'shadowBlur'
13642        ],
13643        [
13644            'shadowColor',
13645            'shadowColor'
13646        ],
13647        [
13648            'shadowOffsetX',
13649            'shadowOffsetX'
13650        ],
13651        [
13652            'shadowOffsetY',
13653            'shadowOffsetY'
13654        ]
13655    ];
13656    Base.prototype.setContext = function (ctx, style) {
13657        for (var i = 0, len = STYLE_CTX_MAP.length; i < len; i++) {
13658            var styleProp = STYLE_CTX_MAP[i][0];
13659            var styleValue = style[styleProp];
13660            var ctxProp = STYLE_CTX_MAP[i][1];
13661            if (typeof styleValue != 'undefined') {
13662                ctx[ctxProp] = styleValue;
13663            }
13664        }
13665    };
13666    var clipShapeInvTransform = matrix.create();
13667    Base.prototype.doClip = function (ctx) {
13668        if (this.__clipShapes && !vmlCanvasManager) {
13669            for (var i = 0; i < this.__clipShapes.length; i++) {
13670                var clipShape = this.__clipShapes[i];
13671                if (clipShape.needTransform) {
13672                    var m = clipShape.transform;
13673                    matrix.invert(clipShapeInvTransform, m);
13674                    ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
13675                }
13676                ctx.beginPath();
13677                clipShape.buildPath(ctx, clipShape.style);
13678                ctx.clip();
13679                if (clipShape.needTransform) {
13680                    var m = clipShapeInvTransform;
13681                    ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
13682                }
13683            }
13684        }
13685    };
13686    Base.prototype.getHighlightStyle = function (style, highlightStyle, brushTypeOnly) {
13687        var newStyle = {};
13688        for (var k in style) {
13689            newStyle[k] = style[k];
13690        }
13691        var color = require('../tool/color');
13692        var highlightColor = color.getHighlightColor();
13693        if (style.brushType != 'stroke') {
13694            newStyle.strokeColor = highlightColor;
13695            newStyle.lineWidth = (style.lineWidth || 1) + this.getHighlightZoom();
13696            newStyle.brushType = 'both';
13697        } else {
13698            if (brushTypeOnly != 'stroke') {
13699                newStyle.strokeColor = highlightColor;
13700                newStyle.lineWidth = (style.lineWidth || 1) + this.getHighlightZoom();
13701            } else {
13702                newStyle.strokeColor = highlightStyle.strokeColor || color.mix(style.strokeColor, color.toRGB(highlightColor));
13703            }
13704        }
13705        for (var k in highlightStyle) {
13706            if (typeof highlightStyle[k] != 'undefined') {
13707                newStyle[k] = highlightStyle[k];
13708            }
13709        }
13710        return newStyle;
13711    };
13712    Base.prototype.getHighlightZoom = function () {
13713        return this.type != 'text' ? 6 : 2;
13714    };
13715    Base.prototype.drift = function (dx, dy) {
13716        this.position[0] += dx;
13717        this.position[1] += dy;
13718    };
13719    Base.prototype.buildPath = function (ctx, style) {
13720        log('buildPath not implemented in ' + this.type);
13721    };
13722    Base.prototype.getRect = function (style) {
13723        log('getRect not implemented in ' + this.type);
13724    };
13725    Base.prototype.isCover = function (x, y) {
13726        var originPos = this.transformCoordToLocal(x, y);
13727        x = originPos[0];
13728        y = originPos[1];
13729        if (this.isCoverRect(x, y)) {
13730            return require('../tool/area').isInside(this, this.style, x, y);
13731        }
13732        return false;
13733    };
13734    Base.prototype.isCoverRect = function (x, y) {
13735        var rect = this.style.__rect;
13736        if (!rect) {
13737            rect = this.style.__rect = this.getRect(this.style);
13738        }
13739        return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
13740    };
13741    Base.prototype.drawText = function (ctx, style, normalStyle) {
13742        if (typeof style.text == 'undefined' || style.text === false) {
13743            return;
13744        }
13745        var textColor = style.textColor || style.color || style.strokeColor;
13746        ctx.fillStyle = textColor;
13747        var dd = 10;
13748        var al;
13749        var bl;
13750        var tx;
13751        var ty;
13752        var textPosition = style.textPosition || this.textPosition || 'top';
13753        switch (textPosition) {
13754        case 'inside':
13755        case 'top':
13756        case 'bottom':
13757        case 'left':
13758        case 'right':
13759            if (this.getRect) {
13760                var rect = (normalStyle || style).__rect || this.getRect(normalStyle || style);
13761                switch (textPosition) {
13762                case 'inside':
13763                    tx = rect.x + rect.width / 2;
13764                    ty = rect.y + rect.height / 2;
13765                    al = 'center';
13766                    bl = 'middle';
13767                    if (style.brushType != 'stroke' && textColor == style.color) {
13768                        ctx.fillStyle = '#fff';
13769                    }
13770                    break;
13771                case 'left':
13772                    tx = rect.x - dd;
13773                    ty = rect.y + rect.height / 2;
13774                    al = 'end';
13775                    bl = 'middle';
13776                    break;
13777                case 'right':
13778                    tx = rect.x + rect.width + dd;
13779                    ty = rect.y + rect.height / 2;
13780                    al = 'start';
13781                    bl = 'middle';
13782                    break;
13783                case 'top':
13784                    tx = rect.x + rect.width / 2;
13785                    ty = rect.y - dd;
13786                    al = 'center';
13787                    bl = 'bottom';
13788                    break;
13789                case 'bottom':
13790                    tx = rect.x + rect.width / 2;
13791                    ty = rect.y + rect.height + dd;
13792                    al = 'center';
13793                    bl = 'top';
13794                    break;
13795                }
13796            }
13797            break;
13798        case 'start':
13799        case 'end':
13800            var pointList = style.pointList || [
13801                [
13802                    style.xStart || 0,
13803                    style.yStart || 0
13804                ],
13805                [
13806                    style.xEnd || 0,
13807                    style.yEnd || 0
13808                ]
13809            ];
13810            var length = pointList.length;
13811            if (length < 2) {
13812                return;
13813            }
13814            var xStart;
13815            var xEnd;
13816            var yStart;
13817            var yEnd;
13818            switch (textPosition) {
13819            case 'start':
13820                xStart = pointList[1][0];
13821                xEnd = pointList[0][0];
13822                yStart = pointList[1][1];
13823                yEnd = pointList[0][1];
13824                break;
13825            case 'end':
13826                xStart = pointList[length - 2][0];
13827                xEnd = pointList[length - 1][0];
13828                yStart = pointList[length - 2][1];
13829                yEnd = pointList[length - 1][1];
13830                break;
13831            }
13832            tx = xEnd;
13833            ty = yEnd;
13834            var angle = Math.atan((yStart - yEnd) / (xEnd - xStart)) / Math.PI * 180;
13835            if (xEnd - xStart < 0) {
13836                angle += 180;
13837            } else if (yStart - yEnd < 0) {
13838                angle += 360;
13839            }
13840            dd = 5;
13841            if (angle >= 30 && angle <= 150) {
13842                al = 'center';
13843                bl = 'bottom';
13844                ty -= dd;
13845            } else if (angle > 150 && angle < 210) {
13846                al = 'right';
13847                bl = 'middle';
13848                tx -= dd;
13849            } else if (angle >= 210 && angle <= 330) {
13850                al = 'center';
13851                bl = 'top';
13852                ty += dd;
13853            } else {
13854                al = 'left';
13855                bl = 'middle';
13856                tx += dd;
13857            }
13858            break;
13859        case 'specific':
13860            tx = style.textX || 0;
13861            ty = style.textY || 0;
13862            al = 'start';
13863            bl = 'middle';
13864            break;
13865        }
13866        if (tx != null && ty != null) {
13867            _fillText(ctx, style.text, tx, ty, style.textFont, style.textAlign || al, style.textBaseline || bl);
13868        }
13869    };
13870    Base.prototype.modSelf = function () {
13871        this.__dirty = true;
13872        if (this.style) {
13873            this.style.__rect = null;
13874        }
13875        if (this.highlightStyle) {
13876            this.highlightStyle.__rect = null;
13877        }
13878    };
13879    Base.prototype.isSilent = function () {
13880        return !(this.hoverable || this.draggable || this.clickable || this.onmousemove || this.onmouseover || this.onmouseout || this.onmousedown || this.onmouseup || this.onclick || this.ondragenter || this.ondragover || this.ondragleave || this.ondrop);
13881    };
13882    util.merge(Base.prototype, Transformable.prototype, true);
13883    util.merge(Base.prototype, Eventful.prototype, true);
13884    return Base;
13885});define('zrender/tool/curve', [
13886    'require',
13887    './vector'
13888], function (require) {
13889    var vector = require('./vector');
13890    'use strict';
13891    var EPSILON = 0.0001;
13892    var THREE_SQRT = Math.sqrt(3);
13893    var ONE_THIRD = 1 / 3;
13894    var _v0 = vector.create();
13895    var _v1 = vector.create();
13896    var _v2 = vector.create();
13897    function isAroundZero(val) {
13898        return val > -EPSILON && val < EPSILON;
13899    }
13900    function isNotAroundZero(val) {
13901        return val > EPSILON || val < -EPSILON;
13902    }
13903    function cubicAt(p0, p1, p2, p3, t) {
13904        var onet = 1 - t;
13905        return onet * onet * (onet * p0 + 3 * t * p1) + t * t * (t * p3 + 3 * onet * p2);
13906    }
13907    function cubicDerivativeAt(p0, p1, p2, p3, t) {
13908        var onet = 1 - t;
13909        return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
13910    }
13911    function cubicRootAt(p0, p1, p2, p3, val, roots) {
13912        var a = p3 + 3 * (p1 - p2) - p0;
13913        var b = 3 * (p2 - p1 * 2 + p0);
13914        var c = 3 * (p1 - p0);
13915        var d = p0 - val;
13916        var A = b * b - 3 * a * c;
13917        var B = b * c - 9 * a * d;
13918        var C = c * c - 3 * b * d;
13919        var n = 0;
13920        if (isAroundZero(A) && isAroundZero(B)) {
13921            if (isAroundZero(b)) {
13922                roots[0] = 0;
13923            } else {
13924                var t1 = -c / b;
13925                if (t1 >= 0 && t1 <= 1) {
13926                    roots[n++] = t1;
13927                }
13928            }
13929        } else {
13930            var disc = B * B - 4 * A * C;
13931            if (isAroundZero(disc)) {
13932                var K = B / A;
13933                var t1 = -b / a + K;
13934                var t2 = -K / 2;
13935                if (t1 >= 0 && t1 <= 1) {
13936                    roots[n++] = t1;
13937                }
13938                if (t2 >= 0 && t2 <= 1) {
13939                    roots[n++] = t2;
13940                }
13941            } else if (disc > 0) {
13942                var discSqrt = Math.sqrt(disc);
13943                var Y1 = A * b + 1.5 * a * (-B + discSqrt);
13944                var Y2 = A * b + 1.5 * a * (-B - discSqrt);
13945                if (Y1 < 0) {
13946                    Y1 = -Math.pow(-Y1, ONE_THIRD);
13947                } else {
13948                    Y1 = Math.pow(Y1, ONE_THIRD);
13949                }
13950                if (Y2 < 0) {
13951                    Y2 = -Math.pow(-Y2, ONE_THIRD);
13952                } else {
13953                    Y2 = Math.pow(Y2, ONE_THIRD);
13954                }
13955                var t1 = (-b - (Y1 + Y2)) / (3 * a);
13956                if (t1 >= 0 && t1 <= 1) {
13957                    roots[n++] = t1;
13958                }
13959            } else {
13960                var T = (2 * A * b - 3 * a * B) / (2 * Math.sqrt(A * A * A));
13961                var theta = Math.acos(T) / 3;
13962                var ASqrt = Math.sqrt(A);
13963                var tmp = Math.cos(theta);
13964                var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
13965                var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
13966                var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
13967                if (t1 >= 0 && t1 <= 1) {
13968                    roots[n++] = t1;
13969                }
13970                if (t2 >= 0 && t2 <= 1) {
13971                    roots[n++] = t2;
13972                }
13973                if (t3 >= 0 && t3 <= 1) {
13974                    roots[n++] = t3;
13975                }
13976            }
13977        }
13978        return n;
13979    }
13980    function cubicExtrema(p0, p1, p2, p3, extrema) {
13981        var b = 6 * p2 - 12 * p1 + 6 * p0;
13982        var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
13983        var c = 3 * p1 - 3 * p0;
13984        var n = 0;
13985        if (isAroundZero(a)) {
13986            if (isNotAroundZero(b)) {
13987                var t1 = -c / b;
13988                if (t1 >= 0 && t1 <= 1) {
13989                    extrema[n++] = t1;
13990                }
13991            }
13992        } else {
13993            var disc = b * b - 4 * a * c;
13994            if (isAroundZero(disc)) {
13995                extrema[0] = -b / (2 * a);
13996            } else if (disc > 0) {
13997                var discSqrt = Math.sqrt(disc);
13998                var t1 = (-b + discSqrt) / (2 * a);
13999                var t2 = (-b - discSqrt) / (2 * a);
14000                if (t1 >= 0 && t1 <= 1) {
14001                    extrema[n++] = t1;
14002                }
14003                if (t2 >= 0 && t2 <= 1) {
14004                    extrema[n++] = t2;
14005                }
14006            }
14007        }
14008        return n;
14009    }
14010    function cubicSubdivide(p0, p1, p2, p3, t, out) {
14011        var p01 = (p1 - p0) * t + p0;
14012        var p12 = (p2 - p1) * t + p1;
14013        var p23 = (p3 - p2) * t + p2;
14014        var p012 = (p12 - p01) * t + p01;
14015        var p123 = (p23 - p12) * t + p12;
14016        var p0123 = (p123 - p012) * t + p012;
14017        out[0] = p0;
14018        out[1] = p01;
14019        out[2] = p012;
14020        out[3] = p0123;
14021        out[4] = p0123;
14022        out[5] = p123;
14023        out[6] = p23;
14024        out[7] = p3;
14025    }
14026    function cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, out) {
14027        var t;
14028        var interval = 0.005;
14029        var d = Infinity;
14030        _v0[0] = x;
14031        _v0[1] = y;
14032        for (var _t = 0; _t < 1; _t += 0.05) {
14033            _v1[0] = cubicAt(x0, x1, x2, x3, _t);
14034            _v1[1] = cubicAt(y0, y1, y2, y3, _t);
14035            var d1 = vector.distSquare(_v0, _v1);
14036            if (d1 < d) {
14037                t = _t;
14038                d = d1;
14039            }
14040        }
14041        d = Infinity;
14042        for (var i = 0; i < 32; i++) {
14043            if (interval < EPSILON) {
14044                break;
14045            }
14046            var prev = t - interval;
14047            var next = t + interval;
14048            _v1[0] = cubicAt(x0, x1, x2, x3, prev);
14049            _v1[1] = cubicAt(y0, y1, y2, y3, prev);
14050            var d1 = vector.distSquare(_v1, _v0);
14051            if (prev >= 0 && d1 < d) {
14052                t = prev;
14053                d = d1;
14054            } else {
14055                _v2[0] = cubicAt(x0, x1, x2, x3, next);
14056                _v2[1] = cubicAt(y0, y1, y2, y3, next);
14057                var d2 = vector.distSquare(_v2, _v0);
14058                if (next <= 1 && d2 < d) {
14059                    t = next;
14060                    d = d2;
14061                } else {
14062                    interval *= 0.5;
14063                }
14064            }
14065        }
14066        if (out) {
14067            out[0] = cubicAt(x0, x1, x2, x3, t);
14068            out[1] = cubicAt(y0, y1, y2, y3, t);
14069        }
14070        return Math.sqrt(d);
14071    }
14072    function quadraticAt(p0, p1, p2, t) {
14073        var onet = 1 - t;
14074        return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
14075    }
14076    function quadraticDerivativeAt(p0, p1, p2, t) {
14077        return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
14078    }
14079    function quadraticRootAt(p0, p1, p2, val, roots) {
14080        var a = p0 - 2 * p1 + p2;
14081        var b = 2 * (p1 - p0);
14082        var c = p0 - val;
14083        var n = 0;
14084        if (isAroundZero(a)) {
14085            if (isNotAroundZero(b)) {
14086                var t1 = -c / b;
14087                if (t1 >= 0 && t1 <= 1) {
14088                    roots[n++] = t1;
14089                }
14090            }
14091        } else {
14092            var disc = b * b - 4 * a * c;
14093            if (isAroundZero(disc)) {
14094                var t1 = -b / (2 * a);
14095                if (t1 >= 0 && t1 <= 1) {
14096                    roots[n++] = t1;
14097                }
14098            } else if (disc > 0) {
14099                var discSqrt = Math.sqrt(disc);
14100                var t1 = (-b + discSqrt) / (2 * a);
14101                var t2 = (-b - discSqrt) / (2 * a);
14102                if (t1 >= 0 && t1 <= 1) {
14103                    roots[n++] = t1;
14104                }
14105                if (t2 >= 0 && t2 <= 1) {
14106                    roots[n++] = t2;
14107                }
14108            }
14109        }
14110        return n;
14111    }
14112    function quadraticExtremum(p0, p1, p2) {
14113        var divider = p0 + p2 - 2 * p1;
14114        if (divider === 0) {
14115            return 0.5;
14116        } else {
14117            return (p0 - p1) / divider;
14118        }
14119    }
14120    function quadraticSubdivide(p0, p1, p2, t, out) {
14121        var p01 = (p1 - p0) * t + p0;
14122        var p12 = (p2 - p1) * t + p1;
14123        var p012 = (p12 - p01) * t + p01;
14124        out[0] = p0;
14125        out[1] = p01;
14126        out[2] = p012;
14127        out[3] = p012;
14128        out[4] = p12;
14129        out[5] = p2;
14130    }
14131    function quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, out) {
14132        var t;
14133        var interval = 0.005;
14134        var d = Infinity;
14135        _v0[0] = x;
14136        _v0[1] = y;
14137        for (var _t = 0; _t < 1; _t += 0.05) {
14138            _v1[0] = quadraticAt(x0, x1, x2, _t);
14139            _v1[1] = quadraticAt(y0, y1, y2, _t);
14140            var d1 = vector.distSquare(_v0, _v1);
14141            if (d1 < d) {
14142                t = _t;
14143                d = d1;
14144            }
14145        }
14146        d = Infinity;
14147        for (var i = 0; i < 32; i++) {
14148            if (interval < EPSILON) {
14149                break;
14150            }
14151            var prev = t - interval;
14152            var next = t + interval;
14153            _v1[0] = quadraticAt(x0, x1, x2, prev);
14154            _v1[1] = quadraticAt(y0, y1, y2, prev);
14155            var d1 = vector.distSquare(_v1, _v0);
14156            if (prev >= 0 && d1 < d) {
14157                t = prev;
14158                d = d1;
14159            } else {
14160                _v2[0] = quadraticAt(x0, x1, x2, next);
14161                _v2[1] = quadraticAt(y0, y1, y2, next);
14162                var d2 = vector.distSquare(_v2, _v0);
14163                if (next <= 1 && d2 < d) {
14164                    t = next;
14165                    d = d2;
14166                } else {
14167                    interval *= 0.5;
14168                }
14169            }
14170        }
14171        if (out) {
14172            out[0] = quadraticAt(x0, x1, x2, t);
14173            out[1] = quadraticAt(y0, y1, y2, t);
14174        }
14175        return Math.sqrt(d);
14176    }
14177    return {
14178        cubicAt: cubicAt,
14179        cubicDerivativeAt: cubicDerivativeAt,
14180        cubicRootAt: cubicRootAt,
14181        cubicExtrema: cubicExtrema,
14182        cubicSubdivide: cubicSubdivide,
14183        cubicProjectPoint: cubicProjectPoint,
14184        quadraticAt: quadraticAt,
14185        quadraticDerivativeAt: quadraticDerivativeAt,
14186        quadraticRootAt: quadraticRootAt,
14187        quadraticExtremum: quadraticExtremum,
14188        quadraticSubdivide: quadraticSubdivide,
14189        quadraticProjectPoint: quadraticProjectPoint
14190    };
14191});define('zrender/mixin/Transformable', [
14192    'require',
14193    '../tool/matrix',
14194    '../tool/vector'
14195], function (require) {
14196    'use strict';
14197    var matrix = require('../tool/matrix');
14198    var vector = require('../tool/vector');
14199    var origin = [
14200        0,
14201        0
14202    ];
14203    var mTranslate = matrix.translate;
14204    var EPSILON = 0.00005;
14205    function isAroundZero(val) {
14206        return val > -EPSILON && val < EPSILON;
14207    }
14208    function isNotAroundZero(val) {
14209        return val > EPSILON || val < -EPSILON;
14210    }
14211    var Transformable = function () {
14212        if (!this.position) {
14213            this.position = [
14214                0,
14215                0
14216            ];
14217        }
14218        if (typeof this.rotation == 'undefined') {
14219            this.rotation = [
14220                0,
14221                0,
14222                0
14223            ];
14224        }
14225        if (!this.scale) {
14226            this.scale = [
14227                1,
14228                1,
14229                0,
14230                0
14231            ];
14232        }
14233        this.needLocalTransform = false;
14234        this.needTransform = false;
14235    };
14236    Transformable.prototype = {
14237        constructor: Transformable,
14238        updateNeedTransform: function () {
14239            this.needLocalTransform = isNotAroundZero(this.rotation[0]) || isNotAroundZero(this.position[0]) || isNotAroundZero(this.position[1]) || isNotAroundZero(this.scale[0] - 1) || isNotAroundZero(this.scale[1] - 1);
14240        },
14241        updateTransform: function () {
14242            this.updateNeedTransform();
14243            var parentHasTransform = this.parent && this.parent.needTransform;
14244            this.needTransform = this.needLocalTransform || parentHasTransform;
14245            if (!this.needTransform) {
14246                return;
14247            }
14248            var m = this.transform || matrix.create();
14249            matrix.identity(m);
14250            if (this.needLocalTransform) {
14251                var scale = this.scale;
14252                if (isNotAroundZero(scale[0]) || isNotAroundZero(scale[1])) {
14253                    origin[0] = -scale[2] || 0;
14254                    origin[1] = -scale[3] || 0;
14255                    var haveOrigin = isNotAroundZero(origin[0]) || isNotAroundZero(origin[1]);
14256                    if (haveOrigin) {
14257                        mTranslate(m, m, origin);
14258                    }
14259                    matrix.scale(m, m, scale);
14260                    if (haveOrigin) {
14261                        origin[0] = -origin[0];
14262                        origin[1] = -origin[1];
14263                        mTranslate(m, m, origin);
14264                    }
14265                }
14266                if (this.rotation instanceof Array) {
14267                    if (this.rotation[0] !== 0) {
14268                        origin[0] = -this.rotation[1] || 0;
14269                        origin[1] = -this.rotation[2] || 0;
14270                        var haveOrigin = isNotAroundZero(origin[0]) || isNotAroundZero(origin[1]);
14271                        if (haveOrigin) {
14272                            mTranslate(m, m, origin);
14273                        }
14274                        matrix.rotate(m, m, this.rotation[0]);
14275                        if (haveOrigin) {
14276                            origin[0] = -origin[0];
14277                            origin[1] = -origin[1];
14278                            mTranslate(m, m, origin);
14279                        }
14280                    }
14281                } else {
14282                    if (this.rotation !== 0) {
14283                        matrix.rotate(m, m, this.rotation);
14284                    }
14285                }
14286                if (isNotAroundZero(this.position[0]) || isNotAroundZero(this.position[1])) {
14287                    mTranslate(m, m, this.position);
14288                }
14289            }
14290            if (parentHasTransform) {
14291                if (this.needLocalTransform) {
14292                    matrix.mul(m, this.parent.transform, m);
14293                } else {
14294                    matrix.copy(m, this.parent.transform);
14295                }
14296            }
14297            this.transform = m;
14298            this.invTransform = this.invTransform || matrix.create();
14299            matrix.invert(this.invTransform, m);
14300        },
14301        setTransform: function (ctx) {
14302            if (this.needTransform) {
14303                var m = this.transform;
14304                ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
14305            }
14306        },
14307        lookAt: function () {
14308            var v = vector.create();
14309            return function (target) {
14310                if (!this.transform) {
14311                    this.transform = matrix.create();
14312                }
14313                var m = this.transform;
14314                vector.sub(v, target, this.position);
14315                if (isAroundZero(v[0]) && isAroundZero(v[1])) {
14316                    return;
14317                }
14318                vector.normalize(v, v);
14319                var scale = this.scale;
14320                m[2] = v[0] * scale[1];
14321                m[3] = v[1] * scale[1];
14322                m[0] = v[1] * scale[0];
14323                m[1] = -v[0] * scale[0];
14324                m[4] = this.position[0];
14325                m[5] = this.position[1];
14326                this.decomposeTransform();
14327            };
14328        }(),
14329        decomposeTransform: function () {
14330            if (!this.transform) {
14331                return;
14332            }
14333            var m = this.transform;
14334            var sx = m[0] * m[0] + m[1] * m[1];
14335            var position = this.position;
14336            var scale = this.scale;
14337            var rotation = this.rotation;
14338            if (isNotAroundZero(sx - 1)) {
14339                sx = Math.sqrt(sx);
14340            }
14341            var sy = m[2] * m[2] + m[3] * m[3];
14342            if (isNotAroundZero(sy - 1)) {
14343                sy = Math.sqrt(sy);
14344            }
14345            position[0] = m[4];
14346            position[1] = m[5];
14347            scale[0] = sx;
14348            scale[1] = sy;
14349            scale[2] = scale[3] = 0;
14350            rotation[0] = Math.atan2(-m[1] / sy, m[0] / sx);
14351            rotation[1] = rotation[2] = 0;
14352        },
14353        transformCoordToLocal: function (x, y) {
14354            var v2 = [
14355                x,
14356                y
14357            ];
14358            if (this.needTransform && this.invTransform) {
14359                vector.applyTransform(v2, v2, this.invTransform);
14360            }
14361            return v2;
14362        }
14363    };
14364    return Transformable;
14365});define('zrender/Group', [
14366    'require',
14367    './tool/guid',
14368    './tool/util',
14369    './mixin/Transformable',
14370    './mixin/Eventful'
14371], function (require) {
14372    var guid = require('./tool/guid');
14373    var util = require('./tool/util');
14374    var Transformable = require('./mixin/Transformable');
14375    var Eventful = require('./mixin/Eventful');
14376    var Group = function (options) {
14377        options = options || {};
14378        this.id = options.id || guid();
14379        for (var key in options) {
14380            this[key] = options[key];
14381        }
14382        this.type = 'group';
14383        this.clipShape = null;
14384        this._children = [];
14385        this._storage = null;
14386        this.__dirty = true;
14387        Transformable.call(this);
14388        Eventful.call(this);
14389    };
14390    Group.prototype.ignore = false;
14391    Group.prototype.children = function () {
14392        return this._children.slice();
14393    };
14394    Group.prototype.childAt = function (idx) {
14395        return this._children[idx];
14396    };
14397    Group.prototype.addChild = function (child) {
14398        if (child == this) {
14399            return;
14400        }
14401        if (child.parent == this) {
14402            return;
14403        }
14404        if (child.parent) {
14405            child.parent.removeChild(child);
14406        }
14407        this._children.push(child);
14408        child.parent = this;
14409        if (this._storage && this._storage !== child._storage) {
14410            this._storage.addToMap(child);
14411            if (child instanceof Group) {
14412                child.addChildrenToStorage(this._storage);
14413            }
14414        }
14415    };
14416    Group.prototype.removeChild = function (child) {
14417        var idx = util.indexOf(this._children, child);
14418        if (idx >= 0) {
14419            this._children.splice(idx, 1);
14420        }
14421        child.parent = null;
14422        if (this._storage) {
14423            this._storage.delFromMap(child.id);
14424            if (child instanceof Group) {
14425                child.delChildrenFromStorage(this._storage);
14426            }
14427        }
14428    };
14429    Group.prototype.clearChildren = function () {
14430        for (var i = 0; i < this._children.length; i++) {
14431            var child = this._children[i];
14432            if (this._storage) {
14433                this._storage.delFromMap(child.id);
14434                if (child instanceof Group) {
14435                    child.delChildrenFromStorage(this._storage);
14436                }
14437            }
14438        }
14439        this._children.length = 0;
14440    };
14441    Group.prototype.eachChild = function (cb, context) {
14442        var haveContext = !!context;
14443        for (var i = 0; i < this._children.length; i++) {
14444            var child = this._children[i];
14445            if (haveContext) {
14446                cb.call(context, child);
14447            } else {
14448                cb(child);
14449            }
14450        }
14451    };
14452    Group.prototype.traverse = function (cb, context) {
14453        var haveContext = !!context;
14454        for (var i = 0; i < this._children.length; i++) {
14455            var child = this._children[i];
14456            if (haveContext) {
14457                cb.call(context, child);
14458            } else {
14459                cb(child);
14460            }
14461            if (child.type === 'group') {
14462                child.traverse(cb, context);
14463            }
14464        }
14465    };
14466    Group.prototype.addChildrenToStorage = function (storage) {
14467        for (var i = 0; i < this._children.length; i++) {
14468            var child = this._children[i];
14469            storage.addToMap(child);
14470            if (child instanceof Group) {
14471                child.addChildrenToStorage(storage);
14472            }
14473        }
14474    };
14475    Group.prototype.delChildrenFromStorage = function (storage) {
14476        for (var i = 0; i < this._children.length; i++) {
14477            var child = this._children[i];
14478            storage.delFromMap(child.id);
14479            if (child instanceof Group) {
14480                child.delChildrenFromStorage(storage);
14481            }
14482        }
14483    };
14484    Group.prototype.modSelf = function () {
14485        this.__dirty = true;
14486    };
14487    util.merge(Group.prototype, Transformable.prototype, true);
14488    util.merge(Group.prototype, Eventful.prototype, true);
14489    return Group;
14490});define('zrender/animation/Clip', [
14491    'require',
14492    './easing'
14493], function (require) {
14494    var Easing = require('./easing');
14495    function Clip(options) {
14496        this._targetPool = options.target || {};
14497        if (!(this._targetPool instanceof Array)) {
14498            this._targetPool = [this._targetPool];
14499        }
14500        this._life = options.life || 1000;
14501        this._delay = options.delay || 0;
14502        this._startTime = new Date().getTime() + this._delay;
14503        this._endTime = this._startTime + this._life * 1000;
14504        this.loop = typeof options.loop == 'undefined' ? false : options.loop;
14505        this.gap = options.gap || 0;
14506        this.easing = options.easing || 'Linear';
14507        this.onframe = options.onframe;
14508        this.ondestroy = options.ondestroy;
14509        this.onrestart = options.onrestart;
14510    }
14511    Clip.prototype = {
14512        step: function (time) {
14513            var percent = (time - this._startTime) / this._life;
14514            if (percent < 0) {
14515                return;
14516            }
14517            percent = Math.min(percent, 1);
14518            var easingFunc = typeof this.easing == 'string' ? Easing[this.easing] : this.easing;
14519            var schedule = typeof easingFunc === 'function' ? easingFunc(percent) : percent;
14520            this.fire('frame', schedule);
14521            if (percent == 1) {
14522                if (this.loop) {
14523                    this.restart();
14524                    return 'restart';
14525                }
14526                this.__needsRemove = true;
14527                return 'destroy';
14528            }
14529            return null;
14530        },
14531        restart: function () {
14532            var time = new Date().getTime();
14533            var remainder = (time - this._startTime) % this._life;
14534            this._startTime = new Date().getTime() - remainder + this.gap;
14535            this.__needsRemove = false;
14536        },
14537        fire: function (eventType, arg) {
14538            for (var i = 0, len = this._targetPool.length; i < len; i++) {
14539                if (this['on' + eventType]) {
14540                    this['on' + eventType](this._targetPool[i], arg);
14541                }
14542            }
14543        },
14544        constructor: Clip
14545    };
14546    return Clip;
14547});define('zrender/animation/easing', [], function () {
14548    var easing = {
14549        Linear: function (k) {
14550            return k;
14551        },
14552        QuadraticIn: function (k) {
14553            return k * k;
14554        },
14555        QuadraticOut: function (k) {
14556            return k * (2 - k);
14557        },
14558        QuadraticInOut: function (k) {
14559            if ((k *= 2) < 1) {
14560                return 0.5 * k * k;
14561            }
14562            return -0.5 * (--k * (k - 2) - 1);
14563        },
14564        CubicIn: function (k) {
14565            return k * k * k;
14566        },
14567        CubicOut: function (k) {
14568            return --k * k * k + 1;
14569        },
14570        CubicInOut: function (k) {
14571            if ((k *= 2) < 1) {
14572                return 0.5 * k * k * k;
14573            }
14574            return 0.5 * ((k -= 2) * k * k + 2);
14575        },
14576        QuarticIn: function (k) {
14577            return k * k * k * k;
14578        },
14579        QuarticOut: function (k) {
14580            return 1 - --k * k * k * k;
14581        },
14582        QuarticInOut: function (k) {
14583            if ((k *= 2) < 1) {
14584                return 0.5 * k * k * k * k;
14585            }
14586            return -0.5 * ((k -= 2) * k * k * k - 2);
14587        },
14588        QuinticIn: function (k) {
14589            return k * k * k * k * k;
14590        },
14591        QuinticOut: function (k) {
14592            return --k * k * k * k * k + 1;
14593        },
14594        QuinticInOut: function (k) {
14595            if ((k *= 2) < 1) {
14596                return 0.5 * k * k * k * k * k;
14597            }
14598            return 0.5 * ((k -= 2) * k * k * k * k + 2);
14599        },
14600        SinusoidalIn: function (k) {
14601            return 1 - Math.cos(k * Math.PI / 2);
14602        },
14603        SinusoidalOut: function (k) {
14604            return Math.sin(k * Math.PI / 2);
14605        },
14606        SinusoidalInOut: function (k) {
14607            return 0.5 * (1 - Math.cos(Math.PI * k));
14608        },
14609        ExponentialIn: function (k) {
14610            return k === 0 ? 0 : Math.pow(1024, k - 1);
14611        },
14612        ExponentialOut: function (k) {
14613            return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
14614        },
14615        ExponentialInOut: function (k) {
14616            if (k === 0) {
14617                return 0;
14618            }
14619            if (k === 1) {
14620                return 1;
14621            }
14622            if ((k *= 2) < 1) {
14623                return 0.5 * Math.pow(1024, k - 1);
14624            }
14625            return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
14626        },
14627        CircularIn: function (k) {
14628            return 1 - Math.sqrt(1 - k * k);
14629        },
14630        CircularOut: function (k) {
14631            return Math.sqrt(1 - --k * k);
14632        },
14633        CircularInOut: function (k) {
14634            if ((k *= 2) < 1) {
14635                return -0.5 * (Math.sqrt(1 - k * k) - 1);
14636            }
14637            return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
14638        },
14639        ElasticIn: function (k) {
14640            var s;
14641            var a = 0.1;
14642            var p = 0.4;
14643            if (k === 0) {
14644                return 0;
14645            }
14646            if (k === 1) {
14647                return 1;
14648            }
14649            if (!a || a < 1) {
14650                a = 1;
14651                s = p / 4;
14652            } else {
14653                s = p * Math.asin(1 / a) / (2 * Math.PI);
14654            }
14655            return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
14656        },
14657        ElasticOut: function (k) {
14658            var s;
14659            var a = 0.1;
14660            var p = 0.4;
14661            if (k === 0) {
14662                return 0;
14663            }
14664            if (k === 1) {
14665                return 1;
14666            }
14667            if (!a || a < 1) {
14668                a = 1;
14669                s = p / 4;
14670            } else {
14671                s = p * Math.asin(1 / a) / (2 * Math.PI);
14672            }
14673            return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
14674        },
14675        ElasticInOut: function (k) {
14676            var s;
14677            var a = 0.1;
14678            var p = 0.4;
14679            if (k === 0) {
14680                return 0;
14681            }
14682            if (k === 1) {
14683                return 1;
14684            }
14685            if (!a || a < 1) {
14686                a = 1;
14687                s = p / 4;
14688            } else {
14689                s = p * Math.asin(1 / a) / (2 * Math.PI);
14690            }
14691            if ((k *= 2) < 1) {
14692                return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
14693            }
14694            return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
14695        },
14696        BackIn: function (k) {
14697            var s = 1.70158;
14698            return k * k * ((s + 1) * k - s);
14699        },
14700        BackOut: function (k) {
14701            var s = 1.70158;
14702            return --k * k * ((s + 1) * k + s) + 1;
14703        },
14704        BackInOut: function (k) {
14705            var s = 1.70158 * 1.525;
14706            if ((k *= 2) < 1) {
14707                return 0.5 * (k * k * ((s + 1) * k - s));
14708            }
14709            return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
14710        },
14711        BounceIn: function (k) {
14712            return 1 - easing.BounceOut(1 - k);
14713        },
14714        BounceOut: function (k) {
14715            if (k < 1 / 2.75) {
14716                return 7.5625 * k * k;
14717            } else if (k < 2 / 2.75) {
14718                return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
14719            } else if (k < 2.5 / 2.75) {
14720                return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
14721            } else {
14722                return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
14723            }
14724        },
14725        BounceInOut: function (k) {
14726            if (k < 0.5) {
14727                return easing.BounceIn(k * 2) * 0.5;
14728            }
14729            return easing.BounceOut(k * 2 - 1) * 0.5 + 0.5;
14730        }
14731    };
14732    return easing;
14733});define('echarts/chart/base', [
14734    'require',
14735    'zrender/shape/Image',
14736    '../util/shape/Icon',
14737    '../util/shape/MarkLine',
14738    '../util/shape/Symbol',
14739    'zrender/shape/Polyline',
14740    'zrender/shape/ShapeBundle',
14741    '../config',
14742    '../util/ecData',
14743    '../util/ecAnimation',
14744    '../util/ecEffect',
14745    '../util/accMath',
14746    '../component/base',
14747    '../layout/EdgeBundling',
14748    'zrender/tool/util',
14749    'zrender/tool/area'
14750], function (require) {
14751    var ImageShape = require('zrender/shape/Image');
14752    var IconShape = require('../util/shape/Icon');
14753    var MarkLineShape = require('../util/shape/MarkLine');
14754    var SymbolShape = require('../util/shape/Symbol');
14755    var PolylineShape = require('zrender/shape/Polyline');
14756    var ShapeBundle = require('zrender/shape/ShapeBundle');
14757    var ecConfig = require('../config');
14758    var ecData = require('../util/ecData');
14759    var ecAnimation = require('../util/ecAnimation');
14760    var ecEffect = require('../util/ecEffect');
14761    var accMath = require('../util/accMath');
14762    var ComponentBase = require('../component/base');
14763    var EdgeBundling = require('../layout/EdgeBundling');
14764    var zrUtil = require('zrender/tool/util');
14765    var zrArea = require('zrender/tool/area');
14766    function isCoordAvailable(coord) {
14767        return coord.x != null && coord.y != null;
14768    }
14769    function Base(ecTheme, messageCenter, zr, option, myChart) {
14770        ComponentBase.call(this, ecTheme, messageCenter, zr, option, myChart);
14771        var self = this;
14772        this.selectedMap = {};
14773        this.lastShapeList = [];
14774        this.shapeHandler = {
14775            onclick: function () {
14776                self.isClick = true;
14777            },
14778            ondragover: function (param) {
14779                var calculableShape = param.target;
14780                calculableShape.highlightStyle = calculableShape.highlightStyle || {};
14781                var highlightStyle = calculableShape.highlightStyle;
14782                var brushType = highlightStyle.brushTyep;
14783                var strokeColor = highlightStyle.strokeColor;
14784                var lineWidth = highlightStyle.lineWidth;
14785                highlightStyle.brushType = 'stroke';
14786                highlightStyle.strokeColor = self.ecTheme.calculableColor || ecConfig.calculableColor;
14787                highlightStyle.lineWidth = calculableShape.type === 'icon' ? 30 : 10;
14788                self.zr.addHoverShape(calculableShape);
14789                setTimeout(function () {
14790                    if (highlightStyle) {
14791                        highlightStyle.brushType = brushType;
14792                        highlightStyle.strokeColor = strokeColor;
14793                        highlightStyle.lineWidth = lineWidth;
14794                    }
14795                }, 20);
14796            },
14797            ondrop: function (param) {
14798                if (ecData.get(param.dragged, 'data') != null) {
14799                    self.isDrop = true;
14800                }
14801            },
14802            ondragend: function () {
14803                self.isDragend = true;
14804            }
14805        };
14806    }
14807    Base.prototype = {
14808        setCalculable: function (shape) {
14809            shape.dragEnableTime = this.ecTheme.DRAG_ENABLE_TIME || ecConfig.DRAG_ENABLE_TIME;
14810            shape.ondragover = this.shapeHandler.ondragover;
14811            shape.ondragend = this.shapeHandler.ondragend;
14812            shape.ondrop = this.shapeHandler.ondrop;
14813            return shape;
14814        },
14815        ondrop: function (param, status) {
14816            if (!this.isDrop || !param.target || status.dragIn) {
14817                return;
14818            }
14819            var target = param.target;
14820            var dragged = param.dragged;
14821            var seriesIndex = ecData.get(target, 'seriesIndex');
14822            var dataIndex = ecData.get(target, 'dataIndex');
14823            var series = this.series;
14824            var data;
14825            var legend = this.component.legend;
14826            if (dataIndex === -1) {
14827                if (ecData.get(dragged, 'seriesIndex') == seriesIndex) {
14828                    status.dragOut = status.dragIn = status.needRefresh = true;
14829                    this.isDrop = false;
14830                    return;
14831                }
14832                data = {
14833                    value: ecData.get(dragged, 'value'),
14834                    name: ecData.get(dragged, 'name')
14835                };
14836                if (this.type === ecConfig.CHART_TYPE_PIE && data.value < 0) {
14837                    data.value = 0;
14838                }
14839                var hasFind = false;
14840                var sData = series[seriesIndex].data;
14841                for (var i = 0, l = sData.length; i < l; i++) {
14842                    if (sData[i].name === data.name && sData[i].value === '-') {
14843                        series[seriesIndex].data[i].value = data.value;
14844                        hasFind = true;
14845                    }
14846                }
14847                !hasFind && series[seriesIndex].data.push(data);
14848                legend && legend.add(data.name, dragged.style.color || dragged.style.strokeColor);
14849            } else {
14850                data = series[seriesIndex].data[dataIndex] || '-';
14851                if (data.value != null) {
14852                    if (data.value != '-') {
14853                        series[seriesIndex].data[dataIndex].value = accMath.accAdd(series[seriesIndex].data[dataIndex].value, ecData.get(dragged, 'value'));
14854                    } else {
14855                        series[seriesIndex].data[dataIndex].value = ecData.get(dragged, 'value');
14856                    }
14857                    if (this.type === ecConfig.CHART_TYPE_FUNNEL || this.type === ecConfig.CHART_TYPE_PIE) {
14858                        legend && legend.getRelatedAmount(data.name) === 1 && this.component.legend.del(data.name);
14859                        data.name += this.option.nameConnector + ecData.get(dragged, 'name');
14860                        legend && legend.add(data.name, dragged.style.color || dragged.style.strokeColor);
14861                    }
14862                } else {
14863                    if (data != '-') {
14864                        series[seriesIndex].data[dataIndex] = accMath.accAdd(series[seriesIndex].data[dataIndex], ecData.get(dragged, 'value'));
14865                    } else {
14866                        series[seriesIndex].data[dataIndex] = ecData.get(dragged, 'value');
14867                    }
14868                }
14869            }
14870            status.dragIn = status.dragIn || true;
14871            this.isDrop = false;
14872            var self = this;
14873            setTimeout(function () {
14874                self.zr.trigger('mousemove', param.event);
14875            }, 300);
14876            return;
14877        },
14878        ondragend: function (param, status) {
14879            if (!this.isDragend || !param.target || status.dragOut) {
14880                return;
14881            }
14882            var target = param.target;
14883            var seriesIndex = ecData.get(target, 'seriesIndex');
14884            var dataIndex = ecData.get(target, 'dataIndex');
14885            var series = this.series;
14886            if (series[seriesIndex].data[dataIndex].value != null) {
14887                series[seriesIndex].data[dataIndex].value = '-';
14888                var name = series[seriesIndex].data[dataIndex].name;
14889                var legend = this.component.legend;
14890                if (legend && legend.getRelatedAmount(name) === 0) {
14891                    legend.del(name);
14892                }
14893            } else {
14894                series[seriesIndex].data[dataIndex] = '-';
14895            }
14896            status.dragOut = true;
14897            status.needRefresh = true;
14898            this.isDragend = false;
14899            return;
14900        },
14901        onlegendSelected: function (param, status) {
14902            var legendSelected = param.selected;
14903            for (var itemName in this.selectedMap) {
14904                if (this.selectedMap[itemName] != legendSelected[itemName]) {
14905                    status.needRefresh = true;
14906                }
14907                this.selectedMap[itemName] = legendSelected[itemName];
14908            }
14909            return;
14910        },
14911        _buildPosition: function () {
14912            this._symbol = this.option.symbolList;
14913            this._sIndex2ShapeMap = {};
14914            this._sIndex2ColorMap = {};
14915            this.selectedMap = {};
14916            this.xMarkMap = {};
14917            var series = this.series;
14918            var _position2sIndexMap = {
14919                top: [],
14920                bottom: [],
14921                left: [],
14922                right: [],
14923                other: []
14924            };
14925            var xAxisIndex;
14926            var yAxisIndex;
14927            var xAxis;
14928            var yAxis;
14929            for (var i = 0, l = series.length; i < l; i++) {
14930                if (series[i].type === this.type) {
14931                    series[i] = this.reformOption(series[i]);
14932                    this.legendHoverLink = series[i].legendHoverLink || this.legendHoverLink;
14933                    xAxisIndex = series[i].xAxisIndex;
14934                    yAxisIndex = series[i].yAxisIndex;
14935                    xAxis = this.component.xAxis.getAxis(xAxisIndex);
14936                    yAxis = this.component.yAxis.getAxis(yAxisIndex);
14937                    if (xAxis.type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY) {
14938                        _position2sIndexMap[xAxis.getPosition()].push(i);
14939                    } else if (yAxis.type === ecConfig.COMPONENT_TYPE_AXIS_CATEGORY) {
14940                        _position2sIndexMap[yAxis.getPosition()].push(i);
14941                    } else {
14942                        _position2sIndexMap.other.push(i);
14943                    }
14944                }
14945            }
14946            for (var position in _position2sIndexMap) {
14947                if (_position2sIndexMap[position].length > 0) {
14948                    this._buildSinglePosition(position, _position2sIndexMap[position]);
14949                }
14950            }
14951            this.addShapeList();
14952        },
14953        _buildSinglePosition: function (position, seriesArray) {
14954            var mapData = this._mapData(seriesArray);
14955            var locationMap = mapData.locationMap;
14956            var maxDataLength = mapData.maxDataLength;
14957            if (maxDataLength === 0 || locationMap.length === 0) {
14958                return;
14959            }
14960            switch (position) {
14961            case 'bottom':
14962            case 'top':
14963                this._buildHorizontal(seriesArray, maxDataLength, locationMap, this.xMarkMap);
14964                break;
14965            case 'left':
14966            case 'right':
14967                this._buildVertical(seriesArray, maxDataLength, locationMap, this.xMarkMap);
14968                break;
14969            case 'other':
14970                this._buildOther(seriesArray, maxDataLength, locationMap, this.xMarkMap);
14971                break;
14972            }
14973            for (var i = 0, l = seriesArray.length; i < l; i++) {
14974                this.buildMark(seriesArray[i]);
14975            }
14976        },
14977        _mapData: function (seriesArray) {
14978            var series = this.series;
14979            var serie;
14980            var dataIndex = 0;
14981            var stackMap = {};
14982            var magicStackKey = '__kener__stack__';
14983            var stackKey;
14984            var serieName;
14985            var legend = this.component.legend;
14986            var locationMap = [];
14987            var maxDataLength = 0;
14988            var iconShape;
14989            for (var i = 0, l = seriesArray.length; i < l; i++) {
14990                serie = series[seriesArray[i]];
14991                serieName = serie.name;
14992                this._sIndex2ShapeMap[seriesArray[i]] = this._sIndex2ShapeMap[seriesArray[i]] || this.query(serie, 'symbol') || this._symbol[i % this._symbol.length];
14993                if (legend) {
14994                    this.selectedMap[serieName] = legend.isSelected(serieName);
14995                    this._sIndex2ColorMap[seriesArray[i]] = legend.getColor(serieName);
14996                    iconShape = legend.getItemShape(serieName);
14997                    if (iconShape) {
14998                        var style = iconShape.style;
14999                        if (this.type == ecConfig.CHART_TYPE_LINE) {
15000                            style.iconType = 'legendLineIcon';
15001                            style.symbol = this._sIndex2ShapeMap[seriesArray[i]];
15002                        } else if (serie.itemStyle.normal.barBorderWidth > 0) {
15003                            var highlightStyle = iconShape.highlightStyle;
15004                            style.brushType = 'both';
15005                            style.x += 1;
15006                            style.y += 1;
15007                            style.width -= 2;
15008                            style.height -= 2;
15009                            style.strokeColor = highlightStyle.strokeColor = serie.itemStyle.normal.barBorderColor;
15010                            highlightStyle.lineWidth = 3;
15011                        }
15012                        legend.setItemShape(serieName, iconShape);
15013                    }
15014                } else {
15015                    this.selectedMap[serieName] = true;
15016                    this._sIndex2ColorMap[seriesArray[i]] = this.zr.getColor(seriesArray[i]);
15017                }
15018                if (this.selectedMap[serieName]) {
15019                    stackKey = serie.stack || magicStackKey + seriesArray[i];
15020                    if (stackMap[stackKey] == null) {
15021                        stackMap[stackKey] = dataIndex;
15022                        locationMap[dataIndex] = [seriesArray[i]];
15023                        dataIndex++;
15024                    } else {
15025                        locationMap[stackMap[stackKey]].push(seriesArray[i]);
15026                    }
15027                }
15028                maxDataLength = Math.max(maxDataLength, serie.data.length);
15029            }
15030            return {
15031                locationMap: locationMap,
15032                maxDataLength: maxDataLength
15033            };
15034        },
15035        _calculMarkMapXY: function (xMarkMap, locationMap, xy) {
15036            var series = this.series;
15037            for (var j = 0, k = locationMap.length; j < k; j++) {
15038                for (var m = 0, n = locationMap[j].length; m < n; m++) {
15039                    var seriesIndex = locationMap[j][m];
15040                    var valueIndex = xy == 'xy' ? 0 : '';
15041                    var grid = this.component.grid;
15042                    var tarMark = xMarkMap[seriesIndex];
15043                    if (xy.indexOf('x') != '-1') {
15044                        if (tarMark['counter' + valueIndex] > 0) {
15045                            tarMark['average' + valueIndex] = tarMark['sum' + valueIndex] / tarMark['counter' + valueIndex];
15046                        }
15047                        var x = this.component.xAxis.getAxis(series[seriesIndex].xAxisIndex || 0).getCoord(tarMark['average' + valueIndex]);
15048                        tarMark['averageLine' + valueIndex] = [
15049                            [
15050                                x,
15051                                grid.getYend()
15052                            ],
15053                            [
15054                                x,
15055                                grid.getY()
15056                            ]
15057                        ];
15058                        tarMark['minLine' + valueIndex] = [
15059                            [
15060                                tarMark['minX' + valueIndex],
15061                                grid.getYend()
15062                            ],
15063                            [
15064                                tarMark['minX' + valueIndex],
15065                                grid.getY()
15066                            ]
15067                        ];
15068                        tarMark['maxLine' + valueIndex] = [
15069                            [
15070                                tarMark['maxX' + valueIndex],
15071                                grid.getYend()
15072                            ],
15073                            [
15074                                tarMark['maxX' + valueIndex],
15075                                grid.getY()
15076                            ]
15077                        ];
15078                        tarMark.isHorizontal = false;
15079                    }
15080                    valueIndex = xy == 'xy' ? 1 : '';
15081                    if (xy.indexOf('y') != '-1') {
15082                        if (tarMark['counter' + valueIndex] > 0) {
15083                            tarMark['average' + valueIndex] = tarMark['sum' + valueIndex] / tarMark['counter' + valueIndex];
15084                        }
15085                        var y = this.component.yAxis.getAxis(series[seriesIndex].yAxisIndex || 0).getCoord(tarMark['average' + valueIndex]);
15086                        tarMark['averageLine' + valueIndex] = [
15087                            [
15088                                grid.getX(),
15089                                y
15090                            ],
15091                            [
15092                                grid.getXend(),
15093                                y
15094                            ]
15095                        ];
15096                        tarMark['minLine' + valueIndex] = [
15097                            [
15098                                grid.getX(),
15099                                tarMark['minY' + valueIndex]
15100                            ],
15101                            [
15102                                grid.getXend(),
15103                                tarMark['minY' + valueIndex]
15104                            ]
15105                        ];
15106                        tarMark['maxLine' + valueIndex] = [
15107                            [
15108                                grid.getX(),
15109                                tarMark['maxY' + valueIndex]
15110                            ],
15111                            [
15112                                grid.getXend(),
15113                                tarMark['maxY' + valueIndex]
15114                            ]
15115                        ];
15116                        tarMark.isHorizontal = true;
15117                    }
15118                }
15119            }
15120        },
15121        addLabel: function (tarShape, serie, data, name, orient) {
15122            var queryTarget = [
15123                data,
15124                serie
15125            ];
15126            var nLabel = this.deepMerge(queryTarget, 'itemStyle.normal.label');
15127            var eLabel = this.deepMerge(queryTarget, 'itemStyle.emphasis.label');
15128            var nTextStyle = nLabel.textStyle || {};
15129            var eTextStyle = eLabel.textStyle || {};
15130            if (nLabel.show) {
15131                var style = tarShape.style;
15132                style.text = this._getLabelText(serie, data, name, 'normal');
15133                style.textPosition = nLabel.position == null ? orient === 'horizontal' ? 'right' : 'top' : nLabel.position;
15134                style.textColor = nTextStyle.color;
15135                style.textFont = this.getFont(nTextStyle);
15136                style.textAlign = nTextStyle.align;
15137                style.textBaseline = nTextStyle.baseline;
15138            }
15139            if (eLabel.show) {
15140                var highlightStyle = tarShape.highlightStyle;
15141                highlightStyle.text = this._getLabelText(serie, data, name, 'emphasis');
15142                highlightStyle.textPosition = nLabel.show ? tarShape.style.textPosition : eLabel.position == null ? orient === 'horizontal' ? 'right' : 'top' : eLabel.position;
15143                highlightStyle.textColor = eTextStyle.color;
15144                highlightStyle.textFont = this.getFont(eTextStyle);
15145                highlightStyle.textAlign = eTextStyle.align;
15146                highlightStyle.textBaseline = eTextStyle.baseline;
15147            }
15148            return tarShape;
15149        },
15150        _getLabelText: function (serie, data, name, status) {
15151            var formatter = this.deepQuery([
15152                data,
15153                serie
15154            ], 'itemStyle.' + status + '.label.formatter');
15155            if (!formatter && status === 'emphasis') {
15156                formatter = this.deepQuery([
15157                    data,
15158                    serie
15159                ], 'itemStyle.normal.label.formatter');
15160            }
15161            var value = this.getDataFromOption(data, '-');
15162            if (formatter) {
15163                if (typeof formatter === 'function') {
15164                    return formatter.call(this.myChart, {
15165                        seriesName: serie.name,
15166                        series: serie,
15167                        name: name,
15168                        value: value,
15169                        data: data,
15170                        status: status
15171                    });
15172                } else if (typeof formatter === 'string') {
15173                    formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}').replace('{a0}', serie.name).replace('{b0}', name).replace('{c0}', this.numAddCommas(value));
15174                    return formatter;
15175                }
15176            } else {
15177                if (value instanceof Array) {
15178                    return value[2] != null ? this.numAddCommas(value[2]) : value[0] + ' , ' + value[1];
15179                } else {
15180                    return this.numAddCommas(value);
15181                }
15182            }
15183        },
15184        buildMark: function (seriesIndex) {
15185            var serie = this.series[seriesIndex];
15186            if (this.selectedMap[serie.name]) {
15187                serie.markLine && this._buildMarkLine(seriesIndex);
15188                serie.markPoint && this._buildMarkPoint(seriesIndex);
15189            }
15190        },
15191        _buildMarkPoint: function (seriesIndex) {
15192            var attachStyle = (this.markAttachStyle || {})[seriesIndex];
15193            var serie = this.series[seriesIndex];
15194            var mpData;
15195            var pos;
15196            var markPoint = zrUtil.clone(serie.markPoint);
15197            for (var i = 0, l = markPoint.data.length; i < l; i++) {
15198                mpData = markPoint.data[i];
15199                pos = this.getMarkCoord(seriesIndex, mpData);
15200                mpData.x = mpData.x != null ? mpData.x : pos[0];
15201                mpData.y = mpData.y != null ? mpData.y : pos[1];
15202                if (mpData.type && (mpData.type === 'max' || mpData.type === 'min')) {
15203                    mpData.value = pos[3];
15204                    mpData.name = mpData.name || mpData.type;
15205                    mpData.symbolSize = mpData.symbolSize || zrArea.getTextWidth(pos[3], this.getFont()) / 2 + 5;
15206                }
15207            }
15208            var shapeList = this._markPoint(seriesIndex, markPoint);
15209            for (var i = 0, l = shapeList.length; i < l; i++) {
15210                var tarShape = shapeList[i];
15211                tarShape.zlevel = serie.zlevel;
15212                tarShape.z = serie.z + 1;
15213                for (var key in attachStyle) {
15214                    tarShape[key] = zrUtil.clone(attachStyle[key]);
15215                }
15216                this.shapeList.push(tarShape);
15217            }
15218            if (this.type === ecConfig.CHART_TYPE_FORCE || this.type === ecConfig.CHART_TYPE_CHORD) {
15219                for (var i = 0, l = shapeList.length; i < l; i++) {
15220                    this.zr.addShape(shapeList[i]);
15221                }
15222            }
15223        },
15224        _buildMarkLine: function (seriesIndex) {
15225            var attachStyle = (this.markAttachStyle || {})[seriesIndex];
15226            var serie = this.series[seriesIndex];
15227            var pos;
15228            var markLine = zrUtil.clone(serie.markLine);
15229            for (var i = 0, l = markLine.data.length; i < l; i++) {
15230                var mlData = markLine.data[i];
15231                if (mlData.type && (mlData.type === 'max' || mlData.type === 'min' || mlData.type === 'average')) {
15232                    pos = this.getMarkCoord(seriesIndex, mlData);
15233                    markLine.data[i] = [
15234                        zrUtil.clone(mlData),
15235                        {}
15236                    ];
15237                    markLine.data[i][0].name = mlData.name || mlData.type;
15238                    markLine.data[i][0].value = mlData.type !== 'average' ? pos[3] : +pos[3].toFixed(markLine.precision != null ? markLine.precision : this.deepQuery([
15239                        this.ecTheme,
15240                        ecConfig
15241                    ], 'markLine.precision'));
15242                    pos = pos[2];
15243                    mlData = [
15244                        {},
15245                        {}
15246                    ];
15247                } else {
15248                    pos = [
15249                        this.getMarkCoord(seriesIndex, mlData[0]),
15250                        this.getMarkCoord(seriesIndex, mlData[1])
15251                    ];
15252                }
15253                if (pos == null || pos[0] == null || pos[1] == null) {
15254                    continue;
15255                }
15256                markLine.data[i][0].x = mlData[0].x != null ? mlData[0].x : pos[0][0];
15257                markLine.data[i][0].y = mlData[0].y != null ? mlData[0].y : pos[0][1];
15258                markLine.data[i][1].x = mlData[1].x != null ? mlData[1].x : pos[1][0];
15259                markLine.data[i][1].y = mlData[1].y != null ? mlData[1].y : pos[1][1];
15260            }
15261            var shapeList = this._markLine(seriesIndex, markLine);
15262            var isLarge = markLine.large;
15263            if (isLarge) {
15264                var shapeBundle = new ShapeBundle({ style: { shapeList: shapeList } });
15265                var firstShape = shapeList[0];
15266                if (firstShape) {
15267                    zrUtil.merge(shapeBundle.style, firstShape.style);
15268                    zrUtil.merge(shapeBundle.highlightStyle = {}, firstShape.highlightStyle);
15269                    shapeBundle.style.brushType = 'stroke';
15270                    shapeBundle.zlevel = serie.zlevel;
15271                    shapeBundle.z = serie.z + 1;
15272                    shapeBundle.hoverable = false;
15273                    for (var key in attachStyle) {
15274                        shapeBundle[key] = zrUtil.clone(attachStyle[key]);
15275                    }
15276                }
15277                this.shapeList.push(shapeBundle);
15278                this.zr.addShape(shapeBundle);
15279                shapeBundle._mark = 'largeLine';
15280                var effect = markLine.effect;
15281                if (effect.show) {
15282                    shapeBundle.effect = effect;
15283                }
15284            } else {
15285                for (var i = 0, l = shapeList.length; i < l; i++) {
15286                    var tarShape = shapeList[i];
15287                    tarShape.zlevel = serie.zlevel;
15288                    tarShape.z = serie.z + 1;
15289                    for (var key in attachStyle) {
15290                        tarShape[key] = zrUtil.clone(attachStyle[key]);
15291                    }
15292                    this.shapeList.push(tarShape);
15293                }
15294                if (this.type === ecConfig.CHART_TYPE_FORCE || this.type === ecConfig.CHART_TYPE_CHORD) {
15295                    for (var i = 0, l = shapeList.length; i < l; i++) {
15296                        this.zr.addShape(shapeList[i]);
15297                    }
15298                }
15299            }
15300        },
15301        _markPoint: function (seriesIndex, mpOption) {
15302            var serie = this.series[seriesIndex];
15303            var component = this.component;
15304            zrUtil.merge(zrUtil.merge(mpOption, zrUtil.clone(this.ecTheme.markPoint || {})), zrUtil.clone(ecConfig.markPoint));
15305            mpOption.name = serie.name;
15306            var pList = [];
15307            var data = mpOption.data;
15308            var itemShape;
15309            var dataRange = component.dataRange;
15310            var legend = component.legend;
15311            var color;
15312            var value;
15313            var queryTarget;
15314            var nColor;
15315            var eColor;
15316            var effect;
15317            var zrWidth = this.zr.getWidth();
15318            var zrHeight = this.zr.getHeight();
15319            if (!mpOption.large) {
15320                for (var i = 0, l = data.length; i < l; i++) {
15321                    if (data[i].x == null || data[i].y == null) {
15322                        continue;
15323                    }
15324                    value = data[i].value != null ? data[i].value : '';
15325                    if (legend) {
15326                        color = legend.getColor(serie.name);
15327                    }
15328                    if (dataRange) {
15329                        color = isNaN(value) ? color : dataRange.getColor(value);
15330                        queryTarget = [
15331                            data[i],
15332                            mpOption
15333                        ];
15334                        nColor = this.deepQuery(queryTarget, 'itemStyle.normal.color') || color;
15335                        eColor = this.deepQuery(queryTarget, 'itemStyle.emphasis.color') || nColor;
15336                        if (nColor == null && eColor == null) {
15337                            continue;
15338                        }
15339                    }
15340                    color = color == null ? this.zr.getColor(seriesIndex) : color;
15341                    data[i].tooltip = data[i].tooltip || mpOption.tooltip || { trigger: 'item' };
15342                    data[i].name = data[i].name != null ? data[i].name : '';
15343                    data[i].value = value;
15344                    itemShape = this.getSymbolShape(mpOption, seriesIndex, data[i], i, data[i].name, this.parsePercent(data[i].x, zrWidth), this.parsePercent(data[i].y, zrHeight), 'pin', color, 'rgba(0,0,0,0)', 'horizontal');
15345                    itemShape._mark = 'point';
15346                    effect = this.deepMerge([
15347                        data[i],
15348                        mpOption
15349                    ], 'effect');
15350                    if (effect.show) {
15351                        itemShape.effect = effect;
15352                    }
15353                    if (serie.type === ecConfig.CHART_TYPE_MAP) {
15354                        itemShape._geo = this.getMarkGeo(data[i]);
15355                    }
15356                    ecData.pack(itemShape, serie, seriesIndex, data[i], i, data[i].name, value);
15357                    pList.push(itemShape);
15358                }
15359            } else {
15360                itemShape = this.getLargeMarkPointShape(seriesIndex, mpOption);
15361                itemShape._mark = 'largePoint';
15362                itemShape && pList.push(itemShape);
15363            }
15364            return pList;
15365        },
15366        _markLine: function () {
15367            function normalizeOptionValue(mlOption, key) {
15368                mlOption[key] = mlOption[key] instanceof Array ? mlOption[key].length > 1 ? mlOption[key] : [
15369                    mlOption[key][0],
15370                    mlOption[key][0]
15371                ] : [
15372                    mlOption[key],
15373                    mlOption[key]
15374                ];
15375            }
15376            return function (seriesIndex, mlOption) {
15377                var serie = this.series[seriesIndex];
15378                var component = this.component;
15379                var dataRange = component.dataRange;
15380                var legend = component.legend;
15381                zrUtil.merge(zrUtil.merge(mlOption, zrUtil.clone(this.ecTheme.markLine || {})), zrUtil.clone(ecConfig.markLine));
15382                var defaultColor = legend ? legend.getColor(serie.name) : this.zr.getColor(seriesIndex);
15383                normalizeOptionValue(mlOption, 'symbol');
15384                normalizeOptionValue(mlOption, 'symbolSize');
15385                normalizeOptionValue(mlOption, 'symbolRotate');
15386                var data = mlOption.data;
15387                var edges = [];
15388                var zrWidth = this.zr.getWidth();
15389                var zrHeight = this.zr.getHeight();
15390                for (var i = 0; i < data.length; i++) {
15391                    var mlData = data[i];
15392                    if (isCoordAvailable(mlData[0]) && isCoordAvailable(mlData[1])) {
15393                        var mergeData = this.deepMerge(mlData);
15394                        var queryTarget = [
15395                            mergeData,
15396                            mlOption
15397                        ];
15398                        var color = defaultColor;
15399                        var value = mergeData.value != null ? mergeData.value : '';
15400                        if (dataRange) {
15401                            color = isNaN(value) ? color : dataRange.getColor(value);
15402                            var nColor = this.deepQuery(queryTarget, 'itemStyle.normal.color') || color;
15403                            var eColor = this.deepQuery(queryTarget, 'itemStyle.emphasis.color') || nColor;
15404                            if (nColor == null && eColor == null) {
15405                                continue;
15406                            }
15407                        }
15408                        mlData[0].tooltip = mergeData.tooltip || mlOption.tooltip || { trigger: 'item' };
15409                        mlData[0].name = mlData[0].name || '';
15410                        mlData[1].name = mlData[1].name || '';
15411                        mlData[0].value = value;
15412                        edges.push({
15413                            points: [
15414                                [
15415                                    this.parsePercent(mlData[0].x, zrWidth),
15416                                    this.parsePercent(mlData[0].y, zrHeight)
15417                                ],
15418                                [
15419                                    this.parsePercent(mlData[1].x, zrWidth),
15420                                    this.parsePercent(mlData[1].y, zrHeight)
15421                                ]
15422                            ],
15423                            rawData: mlData,
15424                            color: color
15425                        });
15426                    }
15427                }
15428                var enableBundling = this.query(mlOption, 'bundling.enable');
15429                if (enableBundling) {
15430                    var edgeBundling = new EdgeBundling();
15431                    edgeBundling.maxTurningAngle = this.query(mlOption, 'bundling.maxTurningAngle') / 180 * Math.PI;
15432                    edges = edgeBundling.run(edges);
15433                }
15434                mlOption.name = serie.name;
15435                var shapeList = [];
15436                for (var i = 0, l = edges.length; i < l; i++) {
15437                    var edge = edges[i];
15438                    var rawEdge = edge.rawEdge || edge;
15439                    var mlData = rawEdge.rawData;
15440                    var value = mlData.value != null ? mlData.value : '';
15441                    var itemShape = this.getMarkLineShape(mlOption, seriesIndex, mlData, i, edge.points, enableBundling, rawEdge.color);
15442                    itemShape._mark = 'line';
15443                    var effect = this.deepMerge([
15444                        mlData[0],
15445                        mlData[1],
15446                        mlOption
15447                    ], 'effect');
15448                    if (effect.show) {
15449                        itemShape.effect = effect;
15450                        itemShape.effect.large = mlOption.large;
15451                    }
15452                    if (serie.type === ecConfig.CHART_TYPE_MAP) {
15453                        itemShape._geo = [
15454                            this.getMarkGeo(mlData[0]),
15455                            this.getMarkGeo(mlData[1])
15456                        ];
15457                    }
15458                    ecData.pack(itemShape, serie, seriesIndex, mlData[0], i, mlData[0].name + (mlData[1].name !== '' ? ' > ' + mlData[1].name : ''), value);
15459                    shapeList.push(itemShape);
15460                }
15461                return shapeList;
15462            };
15463        }(),
15464        getMarkCoord: function () {
15465            return [
15466                0,
15467                0
15468            ];
15469        },
15470        getSymbolShape: function (serie, seriesIndex, data, dataIndex, name, x, y, symbol, color, emptyColor, orient) {
15471            var queryTarget = [
15472                data,
15473                serie
15474            ];
15475            var value = this.getDataFromOption(data, '-');
15476            symbol = this.deepQuery(queryTarget, 'symbol') || symbol;
15477            var symbolSize = this.deepQuery(queryTarget, 'symbolSize');
15478            symbolSize = typeof symbolSize === 'function' ? symbolSize(value) : symbolSize;
15479            if (typeof symbolSize === 'number') {
15480                symbolSize = [
15481                    symbolSize,
15482                    symbolSize
15483                ];
15484            }
15485            var symbolRotate = this.deepQuery(queryTarget, 'symbolRotate');
15486            var normal = this.deepMerge(queryTarget, 'itemStyle.normal');
15487            var emphasis = this.deepMerge(queryTarget, 'itemStyle.emphasis');
15488            var nBorderWidth = normal.borderWidth != null ? normal.borderWidth : normal.lineStyle && normal.lineStyle.width;
15489            if (nBorderWidth == null) {
15490                nBorderWidth = symbol.match('empty') ? 2 : 0;
15491            }
15492            var eBorderWidth = emphasis.borderWidth != null ? emphasis.borderWidth : emphasis.lineStyle && emphasis.lineStyle.width;
15493            if (eBorderWidth == null) {
15494                eBorderWidth = nBorderWidth + 2;
15495            }
15496            var nColor = this.getItemStyleColor(normal.color, seriesIndex, dataIndex, data);
15497            var eColor = this.getItemStyleColor(emphasis.color, seriesIndex, dataIndex, data);
15498            var width = symbolSize[0];
15499            var height = symbolSize[1];
15500            var itemShape = new IconShape({
15501                style: {
15502                    iconType: symbol.replace('empty', '').toLowerCase(),
15503                    x: x - width,
15504                    y: y - height,
15505                    width: width * 2,
15506                    height: height * 2,
15507                    brushType: 'both',
15508                    color: symbol.match('empty') ? emptyColor : nColor || color,
15509                    strokeColor: normal.borderColor || nColor || color,
15510                    lineWidth: nBorderWidth
15511                },
15512                highlightStyle: {
15513                    color: symbol.match('empty') ? emptyColor : eColor || nColor || color,
15514                    strokeColor: emphasis.borderColor || normal.borderColor || eColor || nColor || color,
15515                    lineWidth: eBorderWidth
15516                },
15517                clickable: this.deepQuery(queryTarget, 'clickable')
15518            });
15519            if (symbol.match('image')) {
15520                itemShape.style.image = symbol.replace(new RegExp('^image:\\/\\/'), '');
15521                itemShape = new ImageShape({
15522                    style: itemShape.style,
15523                    highlightStyle: itemShape.highlightStyle,
15524                    clickable: this.deepQuery(queryTarget, 'clickable')
15525                });
15526            }
15527            if (symbolRotate != null) {
15528                itemShape.rotation = [
15529                    symbolRotate * Math.PI / 180,
15530                    x,
15531                    y
15532                ];
15533            }
15534            if (symbol.match('star')) {
15535                itemShape.style.iconType = 'star';
15536                itemShape.style.n = symbol.replace('empty', '').replace('star', '') - 0 || 5;
15537            }
15538            if (symbol === 'none') {
15539                itemShape.invisible = true;
15540                itemShape.hoverable = false;
15541            }
15542            itemShape = this.addLabel(itemShape, serie, data, name, orient);
15543            if (symbol.match('empty')) {
15544                if (itemShape.style.textColor == null) {
15545                    itemShape.style.textColor = itemShape.style.strokeColor;
15546                }
15547                if (itemShape.highlightStyle.textColor == null) {
15548                    itemShape.highlightStyle.textColor = itemShape.highlightStyle.strokeColor;
15549                }
15550            }
15551            ecData.pack(itemShape, serie, seriesIndex, data, dataIndex, name);
15552            itemShape._x = x;
15553            itemShape._y = y;
15554            itemShape._dataIndex = dataIndex;
15555            itemShape._seriesIndex = seriesIndex;
15556            return itemShape;
15557        },
15558        getMarkLineShape: function (mlOption, seriesIndex, data, dataIndex, points, bundling, color) {
15559            var value0 = data[0].value != null ? data[0].value : '-';
15560            var value1 = data[1].value != null ? data[1].value : '-';
15561            var symbol = [
15562                data[0].symbol || mlOption.symbol[0],
15563                data[1].symbol || mlOption.symbol[1]
15564            ];
15565            var symbolSize = [
15566                data[0].symbolSize || mlOption.symbolSize[0],
15567                data[1].symbolSize || mlOption.symbolSize[1]
15568            ];
15569            symbolSize[0] = typeof symbolSize[0] === 'function' ? symbolSize[0](value0) : symbolSize[0];
15570            symbolSize[1] = typeof symbolSize[1] === 'function' ? symbolSize[1](value1) : symbolSize[1];
15571            var symbolRotate = [
15572                this.query(data[0], 'symbolRotate') || mlOption.symbolRotate[0],
15573                this.query(data[1], 'symbolRotate') || mlOption.symbolRotate[1]
15574            ];
15575            var queryTarget = [
15576                data[0],
15577                data[1],
15578                mlOption
15579            ];
15580            var normal = this.deepMerge(queryTarget, 'itemStyle.normal');
15581            normal.color = this.getItemStyleColor(normal.color, seriesIndex, dataIndex, data);
15582            var emphasis = this.deepMerge(queryTarget, 'itemStyle.emphasis');
15583            emphasis.color = this.getItemStyleColor(emphasis.color, seriesIndex, dataIndex, data);
15584            var nlineStyle = normal.lineStyle;
15585            var elineStyle = emphasis.lineStyle;
15586            var nBorderWidth = nlineStyle.width;
15587            if (nBorderWidth == null) {
15588                nBorderWidth = normal.borderWidth;
15589            }
15590            var eBorderWidth = elineStyle.width;
15591            if (eBorderWidth == null) {
15592                eBorderWidth = emphasis.borderWidth != null ? emphasis.borderWidth : nB
15592orderWidth + 2;
15593            }
15594            var smoothness = this.deepQuery(queryTarget, 'smoothness');
15595            if (!this.deepQuery(queryTarget, 'smooth')) {
15596                smoothness = 0;
15597            }
15598            var ShapeCtor = bundling ? PolylineShape : MarkLineShape;
15599            var itemShape = new ShapeCtor({
15600                style: {
15601                    symbol: symbol,
15602                    symbolSize: symbolSize,
15603                    symbolRotate: symbolRotate,
15604                    brushType: 'both',
15605                    lineType: nlineStyle.type,
15606                    shadowColor: nlineStyle.shadowColor || nlineStyle.color || normal.borderColor || normal.color || color,
15607                    shadowBlur: nlineStyle.shadowBlur,
15608                    shadowOffsetX: nlineStyle.shadowOffsetX,
15609                    shadowOffsetY: nlineStyle.shadowOffsetY,
15610                    color: normal.color || color,
15611                    strokeColor: nlineStyle.color || normal.borderColor || normal.color || color,
15612                    lineWidth: nBorderWidth,
15613                    symbolBorderColor: normal.borderColor || normal.color || color,
15614                    symbolBorder: normal.borderWidth
15615                },
15616                highlightStyle: {
15617                    shadowColor: elineStyle.shadowColor,
15618                    shadowBlur: elineStyle.shadowBlur,
15619                    shadowOffsetX: elineStyle.shadowOffsetX,
15620                    shadowOffsetY: elineStyle.shadowOffsetY,
15621                    color: emphasis.color || normal.color || color,
15622                    strokeColor: elineStyle.color || nlineStyle.color || emphasis.borderColor || normal.borderColor || emphasis.color || normal.color || color,
15623                    lineWidth: eBorderWidth,
15624                    symbolBorderColor: emphasis.borderColor || normal.borderColor || emphasis.color || normal.color || color,
15625                    symbolBorder: emphasis.borderWidth == null ? normal.borderWidth + 2 : emphasis.borderWidth
15626                },
15627                clickable: this.deepQuery(queryTarget, 'clickable')
15628            });
15629            var shapeStyle = itemShape.style;
15630            if (bundling) {
15631                shapeStyle.pointList = points;
15632                shapeStyle.smooth = smoothness;
15633            } else {
15634                shapeStyle.xStart = points[0][0];
15635                shapeStyle.yStart = points[0][1];
15636                shapeStyle.xEnd = points[1][0];
15637                shapeStyle.yEnd = points[1][1];
15638                shapeStyle.curveness = smoothness;
15639                itemShape.updatePoints(itemShape.style);
15640            }
15641            itemShape = this.addLabel(itemShape, mlOption, data[0], data[0].name + ' : ' + data[1].name);
15642            return itemShape;
15643        },
15644        getLargeMarkPointShape: function (seriesIndex, mpOption) {
15645            var serie = this.series[seriesIndex];
15646            var component = this.component;
15647            var data = mpOption.data;
15648            var itemShape;
15649            var dataRange = component.dataRange;
15650            var legend = component.legend;
15651            var color;
15652            var value;
15653            var queryTarget = [
15654                data[0],
15655                mpOption
15656            ];
15657            var nColor;
15658            var eColor;
15659            var effect;
15660            if (legend) {
15661                color = legend.getColor(serie.name);
15662            }
15663            if (dataRange) {
15664                value = data[0].value != null ? data[0].value : '';
15665                color = isNaN(value) ? color : dataRange.getColor(value);
15666                nColor = this.deepQuery(queryTarget, 'itemStyle.normal.color') || color;
15667                eColor = this.deepQuery(queryTarget, 'itemStyle.emphasis.color') || nColor;
15668                if (nColor == null && eColor == null) {
15669                    return;
15670                }
15671            }
15672            color = this.deepMerge(queryTarget, 'itemStyle.normal').color || color;
15673            var symbol = this.deepQuery(queryTarget, 'symbol') || 'circle';
15674            symbol = symbol.replace('empty', '').replace(/\d/g, '');
15675            effect = this.deepMerge([
15676                data[0],
15677                mpOption
15678            ], 'effect');
15679            var devicePixelRatio = window.devicePixelRatio || 1;
15680            itemShape = new SymbolShape({
15681                style: {
15682                    pointList: data,
15683                    color: color,
15684                    strokeColor: color,
15685                    shadowColor: effect.shadowColor || color,
15686                    shadowBlur: (effect.shadowBlur != null ? effect.shadowBlur : 8) * devicePixelRatio,
15687                    size: this.deepQuery(queryTarget, 'symbolSize'),
15688                    iconType: symbol,
15689                    brushType: 'fill',
15690                    lineWidth: 1
15691                },
15692                draggable: false,
15693                hoverable: false
15694            });
15695            if (effect.show) {
15696                itemShape.effect = effect;
15697            }
15698            return itemShape;
15699        },
15700        backupShapeList: function () {
15701            if (this.shapeList && this.shapeList.length > 0) {
15702                this.lastShapeList = this.shapeList;
15703                this.shapeList = [];
15704            } else {
15705                this.lastShapeList = [];
15706            }
15707        },
15708        addShapeList: function () {
15709            var maxLenth = this.option.animationThreshold / (this.canvasSupported ? 2 : 4);
15710            var lastShapeList = this.lastShapeList;
15711            var shapeList = this.shapeList;
15712            var isUpdate = lastShapeList.length > 0;
15713            var duration = isUpdate ? this.query(this.option, 'animationDurationUpdate') : this.query(this.option, 'animationDuration');
15714            var easing = this.query(this.option, 'animationEasing');
15715            var delay;
15716            var key;
15717            var oldMap = {};
15718            var newMap = {};
15719            if (this.option.animation && !this.option.renderAsImage && shapeList.length < maxLenth && !this.motionlessOnce) {
15720                for (var i = 0, l = lastShapeList.length; i < l; i++) {
15721                    key = this._getAnimationKey(lastShapeList[i]);
15722                    if (key.match('undefined')) {
15723                        this.zr.delShape(lastShapeList[i].id);
15724                    } else {
15725                        key += lastShapeList[i].type;
15726                        if (oldMap[key]) {
15727                            this.zr.delShape(lastShapeList[i].id);
15728                        } else {
15729                            oldMap[key] = lastShapeList[i];
15730                        }
15731                    }
15732                }
15733                for (var i = 0, l = shapeList.length; i < l; i++) {
15734                    key = this._getAnimationKey(shapeList[i]);
15735                    if (key.match('undefined')) {
15736                        this.zr.addShape(shapeList[i]);
15737                    } else {
15738                        key += shapeList[i].type;
15739                        newMap[key] = shapeList[i];
15740                    }
15741                }
15742                for (key in oldMap) {
15743                    if (!newMap[key]) {
15744                        this.zr.delShape(oldMap[key].id);
15745                    }
15746                }
15747                for (key in newMap) {
15748                    if (oldMap[key]) {
15749                        this.zr.delShape(oldMap[key].id);
15750                        this._animateMod(oldMap[key], newMap[key], duration, easing, 0, isUpdate);
15751                    } else {
15752                        delay = (this.type == ecConfig.CHART_TYPE_LINE || this.type == ecConfig.CHART_TYPE_RADAR) && key.indexOf('icon') !== 0 ? duration / 2 : 0;
15753                        this._animateMod(false, newMap[key], duration, easing, delay, isUpdate);
15754                    }
15755                }
15756                this.zr.refresh();
15757                this.animationEffect();
15758            } else {
15759                this.motionlessOnce = false;
15760                this.zr.delShape(lastShapeList);
15761                for (var i = 0, l = shapeList.length; i < l; i++) {
15762                    this.zr.addShape(shapeList[i]);
15763                }
15764            }
15765        },
15766        _getAnimationKey: function (shape) {
15767            if (this.type != ecConfig.CHART_TYPE_MAP && this.type != ecConfig.CHART_TYPE_TREEMAP && this.type != ecConfig.CHART_TYPE_VENN && this.type != ecConfig.CHART_TYPE_TREE) {
15768                return ecData.get(shape, 'seriesIndex') + '_' + ecData.get(shape, 'dataIndex') + (shape._mark ? shape._mark : '') + (this.type === ecConfig.CHART_TYPE_RADAR ? ecData.get(shape, 'special') : '');
15769            } else {
15770                return ecData.get(shape, 'seriesIndex') + '_' + ecData.get(shape, 'dataIndex') + (shape._mark ? shape._mark : 'undefined');
15771            }
15772        },
15773        _animateMod: function (oldShape, newShape, duration, easing, delay, isUpdate) {
15774            switch (newShape.type) {
15775            case 'polyline':
15776            case 'half-smooth-polygon':
15777                ecAnimation.pointList(this.zr, oldShape, newShape, duration, easing);
15778                break;
15779            case 'rectangle':
15780                ecAnimation.rectangle(this.zr, oldShape, newShape, duration, easing);
15781                break;
15782            case 'image':
15783            case 'icon':
15784                ecAnimation.icon(this.zr, oldShape, newShape, duration, easing, delay);
15785                break;
15786            case 'candle':
15787                if (!isUpdate) {
15788                    ecAnimation.candle(this.zr, oldShape, newShape, duration, easing);
15789                } else {
15790                    this.zr.addShape(newShape);
15791                }
15792                break;
15793            case 'ring':
15794            case 'sector':
15795            case 'circle':
15796                if (!isUpdate) {
15797                    ecAnimation.ring(this.zr, oldShape, newShape, duration + (ecData.get(newShape, 'dataIndex') || 0) % 20 * 100, easing);
15798                } else if (newShape.type === 'sector') {
15799                    ecAnimation.sector(this.zr, oldShape, newShape, duration, easing);
15800                } else {
15801                    this.zr.addShape(newShape);
15802                }
15803                break;
15804            case 'text':
15805                ecAnimation.text(this.zr, oldShape, newShape, duration, easing);
15806                break;
15807            case 'polygon':
15808                if (!isUpdate) {
15809                    ecAnimation.polygon(this.zr, oldShape, newShape, duration, easing);
15810                } else {
15811                    ecAnimation.pointList(this.zr, oldShape, newShape, duration, easing);
15812                }
15813                break;
15814            case 'ribbon':
15815                ecAnimation.ribbon(this.zr, oldShape, newShape, duration, easing);
15816                break;
15817            case 'gauge-pointer':
15818                ecAnimation.gaugePointer(this.zr, oldShape, newShape, duration, easing);
15819                break;
15820            case 'mark-line':
15821                ecAnimation.markline(this.zr, oldShape, newShape, duration, easing);
15822                break;
15823            case 'bezier-curve':
15824            case 'line':
15825                ecAnimation.line(this.zr, oldShape, newShape, duration, easing);
15826                break;
15827            default:
15828                this.zr.addShape(newShape);
15829                break;
15830            }
15831        },
15832        animationMark: function (duration, easing, shapeList) {
15833            var shapeList = shapeList || this.shapeList;
15834            for (var i = 0, l = shapeList.length; i < l; i++) {
15835                if (!shapeList[i]._mark) {
15836                    continue;
15837                }
15838                this._animateMod(false, shapeList[i], duration, easing, 0, true);
15839            }
15840            this.animationEffect(shapeList);
15841        },
15842        animationEffect: function (shapeList) {
15843            !shapeList && this.clearEffectShape();
15844            shapeList = shapeList || this.shapeList;
15845            if (shapeList == null) {
15846                return;
15847            }
15848            var zlevel = ecConfig.EFFECT_ZLEVEL;
15849            if (this.canvasSupported) {
15850                this.zr.modLayer(zlevel, {
15851                    motionBlur: true,
15852                    lastFrameAlpha: this.option.effectBlendAlpha || ecConfig.effectBlendAlpha
15853                });
15854            }
15855            var shape;
15856            for (var i = 0, l = shapeList.length; i < l; i++) {
15857                shape = shapeList[i];
15858                if (!(shape._mark && shape.effect && shape.effect.show && ecEffect[shape._mark])) {
15859                    continue;
15860                }
15861                ecEffect[shape._mark](this.zr, this.effectList, shape, zlevel);
15862                this.effectList[this.effectList.length - 1]._mark = shape._mark;
15863            }
15864        },
15865        clearEffectShape: function (clearMotionBlur) {
15866            var effectList = this.effectList;
15867            if (this.zr && effectList && effectList.length > 0) {
15868                clearMotionBlur && this.zr.modLayer(ecConfig.EFFECT_ZLEVEL, { motionBlur: false });
15869                this.zr.delShape(effectList);
15870                for (var i = 0; i < effectList.length; i++) {
15871                    if (effectList[i].effectAnimator) {
15872                        effectList[i].effectAnimator.stop();
15873                    }
15874                }
15875            }
15876            this.effectList = [];
15877        },
15878        addMark: function (seriesIndex, markData, markType) {
15879            var serie = this.series[seriesIndex];
15880            if (this.selectedMap[serie.name]) {
15881                var duration = this.query(this.option, 'animationDurationUpdate');
15882                var easing = this.query(this.option, 'animationEasing');
15883                var oriMarkData = serie[markType].data;
15884                var lastLength = this.shapeList.length;
15885                serie[markType].data = markData.data;
15886                this['_build' + markType.replace('m', 'M')](seriesIndex);
15887                if (this.option.animation && !this.option.renderAsImage) {
15888                    this.animationMark(duration, easing, this.shapeList.slice(lastLength));
15889                } else {
15890                    for (var i = lastLength, l = this.shapeList.length; i < l; i++) {
15891                        this.zr.addShape(this.shapeList[i]);
15892                    }
15893                    this.zr.refreshNextFrame();
15894                }
15895                serie[markType].data = oriMarkData;
15896            }
15897        },
15898        delMark: function (seriesIndex, markName, markType) {
15899            markType = markType.replace('mark', '').replace('large', '').toLowerCase();
15900            var serie = this.series[seriesIndex];
15901            if (this.selectedMap[serie.name]) {
15902                var needRefresh = false;
15903                var shapeList = [
15904                    this.shapeList,
15905                    this.effectList
15906                ];
15907                var len = 2;
15908                while (len--) {
15909                    for (var i = 0, l = shapeList[len].length; i < l; i++) {
15910                        if (shapeList[len][i]._mark == markType && ecData.get(shapeList[len][i], 'seriesIndex') == seriesIndex && ecData.get(shapeList[len][i], 'name') == markName) {
15911                            this.zr.delShape(shapeList[len][i].id);
15912                            shapeList[len].splice(i, 1);
15913                            needRefresh = true;
15914                            break;
15915                        }
15916                    }
15917                }
15918                needRefresh && this.zr.refreshNextFrame();
15919            }
15920        }
15921    };
15922    zrUtil.inherits(Base, ComponentBase);
15923    return Base;
15924});define('zrender/shape/Circle', [
15925    'require',
15926    './Base',
15927    '../tool/util'
15928], function (require) {
15929    'use strict';
15930    var Base = require('./Base');
15931    var Circle = function (options) {
15932        Base.call(this, options);
15933    };
15934    Circle.prototype = {
15935        type: 'circle',
15936        buildPath: function (ctx, style) {
15937            ctx.moveTo(style.x + style.r, style.y);
15938            ctx.arc(style.x, style.y, style.r, 0, Math.PI * 2, true);
15939            return;
15940        },
15941        getRect: function (style) {
15942            if (style.__rect) {
15943                return style.__rect;
15944            }
15945            var lineWidth;
15946            if (style.brushType == 'stroke' || style.brushType == 'fill') {
15947                lineWidth = style.lineWidth || 1;
15948            } else {
15949                lineWidth = 0;
15950            }
15951            style.__rect = {
15952                x: Math.round(style.x - style.r - lineWidth / 2),
15953                y: Math.round(style.y - style.r - lineWidth / 2),
15954                width: style.r * 2 + lineWidth,
15955                height: style.r * 2 + lineWidth
15956            };
15957            return style.__rect;
15958        }
15959    };
15960    require('../tool/util').inherits(Circle, Base);
15961    return Circle;
15962});define('echarts/util/accMath', [], function () {
15963    function accDiv(arg1, arg2) {
15964        var s1 = arg1.toString();
15965        var s2 = arg2.toString();
15966        var m = 0;
15967        try {
15968            m = s2.split('.')[1].length;
15969        } catch (e) {
15970        }
15971        try {
15972            m -= s1.split('.')[1].length;
15973        } catch (e) {
15974        }
15975        return (s1.replace('.', '') - 0) / (s2.replace('.', '') - 0) * Math.pow(10, m);
15976    }
15977    function accMul(arg1, arg2) {
15978        var s1 = arg1.toString();
15979        var s2 = arg2.toString();
15980        var m = 0;
15981        try {
15982            m += s1.split('.')[1].length;
15983        } catch (e) {
15984        }
15985        try {
15986            m += s2.split('.')[1].length;
15987        } catch (e) {
15988        }
15989        return (s1.replace('.', '') - 0) * (s2.replace('.', '') - 0) / Math.pow(10, m);
15990    }
15991    function accAdd(arg1, arg2) {
15992        var r1 = 0;
15993        var r2 = 0;
15994        try {
15995            r1 = arg1.toString().split('.')[1].length;
15996        } catch (e) {
15997        }
15998        try {
15999            r2 = arg2.toString().split('.')[1].length;
16000        } catch (e) {
16001        }
16002        var m = Math.pow(10, Math.max(r1, r2));
16003        return (Math.round(arg1 * m) + Math.round(arg2 * m)) / m;
16004    }
16005    function accSub(arg1, arg2) {
16006        return accAdd(arg1, -arg2);
16007    }
16008    return {
16009        accDiv: accDiv,
16010        accMul: accMul,
16011        accAdd: accAdd,
16012        accSub: accSub
16013    };
16014});define('echarts/util/shape/Icon', [
16015    'require',
16016    'zrender/tool/util',
16017    'zrender/shape/Star',
16018    'zrender/shape/Heart',
16019    'zrender/shape/Droplet',
16020    'zrender/shape/Image',
16021    'zrender/shape/Base'
16022], function (require) {
16023    var zrUtil = require('zrender/tool/util');
16024    function _iconMark(ctx, style) {
16025        var x = style.x;
16026        var y = style.y;
16027        var dx = style.width / 16;
16028        var dy = style.height / 16;
16029        ctx.moveTo(x, y + style.height);
16030        ctx.lineTo(x + 5 * dx, y + 14 * dy);
16031        ctx.lineTo(x + style.width, y + 3 * dy);
16032        ctx.lineTo(x + 13 * dx, y);
16033        ctx.lineTo(x + 2 * dx, y + 11 * dy);
16034        ctx.lineTo(x, y + style.height);
16035        ctx.moveTo(x + 6 * dx, y + 10 * dy);
16036        ctx.lineTo(x + 14 * dx, y + 2 * dy);
16037        ctx.moveTo(x + 10 * dx, y + 13 * dy);
16038        ctx.lineTo(x + style.width, y + 13 * dy);
16039        ctx.moveTo(x + 13 * dx, y + 10 * dy);
16040        ctx.lineTo(x + 13 * dx, y + style.height);
16041    }
16042    function _iconMarkUndo(ctx, style) {
16043        var x = style.x;
16044        var y = style.y;
16045        var dx = style.width / 16;
16046        var dy = style.height / 16;
16047        ctx.moveTo(x, y + style.height);
16048        ctx.lineTo(x + 5 * dx, y + 14 * dy);
16049        ctx.lineTo(x + style.width, y + 3 * dy);
16050        ctx.lineTo(x + 13 * dx, y);
16051        ctx.lineTo(x + 2 * dx, y + 11 * dy);
16052        ctx.lineTo(x, y + style.height);
16053        ctx.moveTo(x + 6 * dx, y + 10 * dy);
16054        ctx.lineTo(x + 14 * dx, y + 2 * dy);
16055        ctx.moveTo(x + 10 * dx, y + 13 * dy);
16056        ctx.lineTo(x + style.width, y + 13 * dy);
16057    }
16058    function _iconMarkClear(ctx, style) {
16059        var x = style.x;
16060        var y = style.y;
16061        var dx = style.width / 16;
16062        var dy = style.height / 16;
16063        ctx.moveTo(x + 4 * dx, y + 15 * dy);
16064        ctx.lineTo(x + 9 * dx, y + 13 * dy);
16065        ctx.lineTo(x + 14 * dx, y + 8 * dy);
16066        ctx.lineTo(x + 11 * dx, y + 5 * dy);
16067        ctx.lineTo(x + 6 * dx, y + 10 * dy);
16068        ctx.lineTo(x + 4 * dx, y + 15 * dy);
16069        ctx.moveTo(x + 5 * dx, y);
16070        ctx.lineTo(x + 11 * dx, y);
16071        ctx.moveTo(x + 5 * dx, y + dy);
16072        ctx.lineTo(x + 11 * dx, y + dy);
16073        ctx.moveTo(x, y + 2 * dy);
16074        ctx.lineTo(x + style.width, y + 2 * dy);
16075        ctx.moveTo(x, y + 5 * dy);
16076        ctx.lineTo(x + 3 * dx, y + style.height);
16077        ctx.lineTo(x + 13 * dx, y + style.height);
16078        ctx.lineTo(x + style.width, y + 5 * dy);
16079    }
16080    function _iconDataZoom(ctx, style) {
16081        var x = style.x;
16082        var y = style.y;
16083        var dx = style.width / 16;
16084        var dy = style.height / 16;
16085        ctx.moveTo(x, y + 3 * dy);
16086        ctx.lineTo(x + 6 * dx, y + 3 * dy);
16087        ctx.moveTo(x + 3 * dx, y);
16088        ctx.lineTo(x + 3 * dx, y + 6 * dy);
16089        ctx.moveTo(x + 3 * dx, y + 8 * dy);
16090        ctx.lineTo(x + 3 * dx, y + style.height);
16091        ctx.lineTo(x + style.width, y + style.height);
16092        ctx.lineTo(x + style.width, y + 3 * dy);
16093        ctx.lineTo(x + 8 * dx, y + 3 * dy);
16094    }
16095    function _iconDataZoomReset(ctx, style) {
16096        var x = style.x;
16097        var y = style.y;
16098        var dx = style.width / 16;
16099        var dy = style.height / 16;
16100        ctx.moveTo(x + 6 * dx, y);
16101        ctx.lineTo(x + 2 * dx, y + 3 * dy);
16102        ctx.lineTo(x + 6 * dx, y + 6 * dy);
16103        ctx.moveTo(x + 2 * dx, y + 3 * dy);
16104        ctx.lineTo(x + 14 * dx, y + 3 * dy);
16105        ctx.lineTo(x + 14 * dx, y + 11 * dy);
16106        ctx.moveTo(x + 2 * dx, y + 5 * dy);
16107        ctx.lineTo(x + 2 * dx, y + 13 * dy);
16108        ctx.lineTo(x + 14 * dx, y + 13 * dy);
16109        ctx.moveTo(x + 10 * dx, y + 10 * dy);
16110        ctx.lineTo(x + 14 * dx, y + 13 * dy);
16111        ctx.lineTo(x + 10 * dx, y + style.height);
16112    }
16113    function _iconRestore(ctx, style) {
16114        var x = style.x;
16115        var y = style.y;
16116        var dx = style.width / 16;
16117        var dy = style.height / 16;
16118        var r = style.width / 2;
16119        ctx.lineWidth = 1.5;
16120        ctx.arc(x + r, y + r, r - dx, 0, Math.PI * 2 / 3);
16121        ctx.moveTo(x + 3 * dx, y + style.height);
16122        ctx.lineTo(x + 0 * dx, y + 12 * dy);
16123        ctx.lineTo(x + 5 * dx, y + 11 * dy);
16124        ctx.moveTo(x, y + 8 * dy);
16125        ctx.arc(x + r, y + r, r - dx, Math.PI, Math.PI * 5 / 3);
16126        ctx.moveTo(x + 13 * dx, y);
16127        ctx.lineTo(x + style.width, y + 4 * dy);
16128        ctx.lineTo(x + 11 * dx, y + 5 * dy);
16129    }
16130    function _iconLineChart(ctx, style) {
16131        var x = style.x;
16132        var y = style.y;
16133        var dx = style.width / 16;
16134        var dy = style.height / 16;
16135        ctx.moveTo(x, y);
16136        ctx.lineTo(x, y + style.height);
16137        ctx.lineTo(x + style.width, y + style.height);
16138        ctx.moveTo(x + 2 * dx, y + 14 * dy);
16139        ctx.lineTo(x + 7 * dx, y + 6 * dy);
16140        ctx.lineTo(x + 11 * dx, y + 11 * dy);
16141        ctx.lineTo(x + 15 * dx, y + 2 * dy);
16142    }
16143    function _iconBarChart(ctx, style) {
16144        var x = style.x;
16145        var y = style.y;
16146        var dx = style.width / 16;
16147        var dy = style.height / 16;
16148        ctx.moveTo(x, y);
16149        ctx.lineTo(x, y + style.height);
16150        ctx.lineTo(x + style.width, y + style.height);
16151        ctx.moveTo(x + 3 * dx, y + 14 * dy);
16152        ctx.lineTo(x + 3 * dx, y + 6 * dy);
16153        ctx.lineTo(x + 4 * dx, y + 6 * dy);
16154        ctx.lineTo(x + 4 * dx, y + 14 * dy);
16155        ctx.moveTo(x + 7 * dx, y + 14 * dy);
16156        ctx.lineTo(x + 7 * dx, y + 2 * dy);
16157        ctx.lineTo(x + 8 * dx, y + 2 * dy);
16158        ctx.lineTo(x + 8 * dx, y + 14 * dy);
16159        ctx.moveTo(x + 11 * dx, y + 14 * dy);
16160        ctx.lineTo(x + 11 * dx, y + 9 * dy);
16161        ctx.lineTo(x + 12 * dx, y + 9 * dy);
16162        ctx.lineTo(x + 12 * dx, y + 14 * dy);
16163    }
16164    function _iconPieChart(ctx, style) {
16165        var x = style.x;
16166        var y = style.y;
16167        var width = style.width - 2;
16168        var height = style.height - 2;
16169        var r = Math.min(width, height) / 2;
16170        y += 2;
16171        ctx.moveTo(x + r + 3, y + r - 3);
16172        ctx.arc(x + r + 3, y + r - 3, r - 1, 0, -Math.PI / 2, true);
16173        ctx.lineTo(x + r + 3, y + r - 3);
16174        ctx.moveTo(x + r, y);
16175        ctx.lineTo(x + r, y + r);
16176        ctx.arc(x + r, y + r, r, -Math.PI / 2, Math.PI * 2, true);
16177        ctx.lineTo(x + r, y + r);
16178        ctx.lineWidth = 1.5;
16179    }
16180    function _iconFunnelChart(ctx, style) {
16181        var x = style.x;
16182        var y = style.y;
16183        var dx = style.width / 16;
16184        var dy = style.height / 16;
16185        y -= dy;
16186        ctx.moveTo(x + 1 * dx, y + 2 * dy);
16187        ctx.lineTo(x + 15 * dx, y + 2 * dy);
16188        ctx.lineTo(x + 14 * dx, y + 3 * dy);
16189        ctx.lineTo(x + 2 * dx, y + 3 * dy);
16190        ctx.moveTo(x + 3 * dx, y + 6 * dy);
16191        ctx.lineTo(x + 13 * dx, y + 6 * dy);
16192        ctx.lineTo(x + 12 * dx, y + 7 * dy);
16193        ctx.lineTo(x + 4 * dx, y + 7 * dy);
16194        ctx.moveTo(x + 5 * dx, y + 10 * dy);
16195        ctx.lineTo(x + 11 * dx, y + 10 * dy);
16196        ctx.lineTo(x + 10 * dx, y + 11 * dy);
16197        ctx.lineTo(x + 6 * dx, y + 11 * dy);
16198        ctx.moveTo(x + 7 * dx, y + 14 * dy);
16199        ctx.lineTo(x + 9 * dx, y + 14 * dy);
16200        ctx.lineTo(x + 8 * dx, y + 15 * dy);
16201        ctx.lineTo(x + 7 * dx, y + 15 * dy);
16202    }
16203    function _iconForceChart(ctx, style) {
16204        var x = style.x;
16205        var y = style.y;
16206        var width = style.width;
16207        var height = style.height;
16208        var dx = width / 16;
16209        var dy = height / 16;
16210        var r = Math.min(dx, dy) * 2;
16211        ctx.moveTo(x + dx + r, y + dy + r);
16212        ctx.arc(x + dx, y + dy, r, Math.PI / 4, Math.PI * 3);
16213        ctx.lineTo(x + 7 * dx - r, y + 6 * dy - r);
16214        ctx.arc(x + 7 * dx, y + 6 * dy, r, Math.PI / 4 * 5, Math.PI * 4);
16215        ctx.arc(x + 7 * dx, y + 6 * dy, r / 2, Math.PI / 4 * 5, Math.PI * 4);
16216        ctx.moveTo(x + 7 * dx - r / 2, y + 6 * dy + r);
16217        ctx.lineTo(x + dx + r, y + 14 * dy - r);
16218        ctx.arc(x + dx, y + 14 * dy, r, -Math.PI / 4, Math.PI * 2);
16219        ctx.moveTo(x + 7 * dx + r / 2, y + 6 * dy);
16220        ctx.lineTo(x + 14 * dx - r, y + 10 * dy - r / 2);
16221        ctx.moveTo(x + 16 * dx, y + 10 * dy);
16222        ctx.arc(x + 14 * dx, y + 10 * dy, r, 0, Math.PI * 3);
16223        ctx.lineWidth = 1.5;
16224    }
16225    function _iconChordChart(ctx, style) {
16226        var x = style.x;
16227        var y = style.y;
16228        var width = style.width;
16229        var height = style.height;
16230        var r = Math.min(width, height) / 2;
16231        ctx.moveTo(x + width, y + height / 2);
16232        ctx.arc(x + r, y + r, r, 0, Math.PI * 2);
16233        ctx.arc(x + r, y, r, Math.PI / 4, Math.PI / 5 * 4);
16234        ctx.arc(x, y + r, r, -Math.PI / 3, Math.PI / 3);
16235        ctx.arc(x + width, y + height, r, Math.PI, Math.PI / 2 * 3);
16236        ctx.lineWidth = 1.5;
16237    }
16238    function _iconStackChart(ctx, style) {
16239        var x = style.x;
16240        var y = style.y;
16241        var width = style.width;
16242        var height = style.height;
16243        var dy = Math.round(height / 3);
16244        var delta = Math.round((dy - 2) / 2);
16245        var len = 3;
16246        while (len--) {
16247            ctx.rect(x, y + dy * len + delta, width, 2);
16248        }
16249    }
16250    function _iconTiledChart(ctx, style) {
16251        var x = style.x;
16252        var y = style.y;
16253        var width = style.width;
16254        var height = style.height;
16255        var dx = Math.round(width / 3);
16256        var delta = Math.round((dx - 2) / 2);
16257        var len = 3;
16258        while (len--) {
16259            ctx.rect(x + dx * len + delta, y, 2, height);
16260        }
16261    }
16262    function _iconDataView(ctx, style) {
16263        var x = style.x;
16264        var y = style.y;
16265        var dx = style.width / 16;
16266        ctx.moveTo(x + dx, y);
16267        ctx.lineTo(x + dx, y + style.height);
16268        ctx.lineTo(x + 15 * dx, y + style.height);
16269        ctx.lineTo(x + 15 * dx, y);
16270        ctx.lineTo(x + dx, y);
16271        ctx.moveTo(x + 3 * dx, y + 3 * dx);
16272        ctx.lineTo(x + 13 * dx, y + 3 * dx);
16273        ctx.moveTo(x + 3 * dx, y + 6 * dx);
16274        ctx.lineTo(x + 13 * dx, y + 6 * dx);
16275        ctx.moveTo(x + 3 * dx, y + 9 * dx);
16276        ctx.lineTo(x + 13 * dx, y + 9 * dx);
16277        ctx.moveTo(x + 3 * dx, y + 12 * dx);
16278        ctx.lineTo(x + 9 * dx, y + 12 * dx);
16279    }
16280    function _iconSave(ctx, style) {
16281        var x = style.x;
16282        var y = style.y;
16283        var dx = style.width / 16;
16284        var dy = style.height / 16;
16285        ctx.moveTo(x, y);
16286        ctx.lineTo(x, y + style.height);
16287        ctx.lineTo(x + style.width, y + style.height);
16288        ctx.lineTo(x + style.width, y);
16289        ctx.lineTo(x, y);
16290        ctx.moveTo(x + 4 * dx, y);
16291        ctx.lineTo(x + 4 * dx, y + 8 * dy);
16292        ctx.lineTo(x + 12 * dx, y + 8 * dy);
16293        ctx.lineTo(x + 12 * dx, y);
16294        ctx.moveTo(x + 6 * dx, y + 11 * dy);
16295        ctx.lineTo(x + 6 * dx, y + 13 * dy);
16296        ctx.lineTo(x + 10 * dx, y + 13 * dy);
16297        ctx.lineTo(x + 10 * dx, y + 11 * dy);
16298        ctx.lineTo(x + 6 * dx, y + 11 * dy);
16299    }
16300    function _iconCross(ctx, style) {
16301        var x = style.x;
16302        var y = style.y;
16303        var width = style.width;
16304        var height = style.height;
16305        ctx.moveTo(x, y + height / 2);
16306        ctx.lineTo(x + width, y + height / 2);
16307        ctx.moveTo(x + width / 2, y);
16308        ctx.lineTo(x + width / 2, y + height);
16309    }
16310    function _iconCircle(ctx, style) {
16311        var width = style.width / 2;
16312        var height = style.height / 2;
16313        var r = Math.min(width, height);
16314        ctx.moveTo(style.x + width + r, style.y + height);
16315        ctx.arc(style.x + width, style.y + height, r, 0, Math.PI * 2);
16316        ctx.closePath();
16317    }
16318    function _iconRectangle(ctx, style) {
16319        ctx.rect(style.x, style.y, style.width, style.height);
16320        ctx.closePath();
16321    }
16322    function _iconTriangle(ctx, style) {
16323        var width = style.width / 2;
16324        var height = style.height / 2;
16325        var x = style.x + width;
16326        var y = style.y + height;
16327        var symbolSize = Math.min(width, height);
16328        ctx.moveTo(x, y - symbolSize);
16329        ctx.lineTo(x + symbolSize, y + symbolSize);
16330        ctx.lineTo(x - symbolSize, y + symbolSize);
16331        ctx.lineTo(x, y - symbolSize);
16332        ctx.closePath();
16333    }
16334    function _iconDiamond(ctx, style) {
16335        var width = style.width / 2;
16336        var height = style.height / 2;
16337        var x = style.x + width;
16338        var y = style.y + height;
16339        var symbolSize = Math.min(width, height);
16340        ctx.moveTo(x, y - symbolSize);
16341        ctx.lineTo(x + symbolSize, y);
16342        ctx.lineTo(x, y + symbolSize);
16343        ctx.lineTo(x - symbolSize, y);
16344        ctx.lineTo(x, y - symbolSize);
16345        ctx.closePath();
16346    }
16347    function _iconArrow(ctx, style) {
16348        var x = style.x;
16349        var y = style.y;
16350        var dx = style.width / 16;
16351        ctx.moveTo(x + 8 * dx, y);
16352        ctx.lineTo(x + dx, y + style.height);
16353        ctx.lineTo(x + 8 * dx, y + style.height / 4 * 3);
16354        ctx.lineTo(x + 15 * dx, y + style.height);
16355        ctx.lineTo(x +
16355 8 * dx, y);
16356        ctx.closePath();
16357    }
16358    function _iconStar(ctx, style) {
16359        var StarShape = require('zrender/shape/Star');
16360        var width = style.width / 2;
16361        var height = style.height / 2;
16362        StarShape.prototype.buildPath(ctx, {
16363            x: style.x + width,
16364            y: style.y + height,
16365            r: Math.min(width, height),
16366            n: style.n || 5
16367        });
16368    }
16369    function _iconHeart(ctx, style) {
16370        var HeartShape = require('zrender/shape/Heart');
16371        HeartShape.prototype.buildPath(ctx, {
16372            x: style.x + style.width / 2,
16373            y: style.y + style.height * 0.2,
16374            a: style.width / 2,
16375            b: style.height * 0.8
16376        });
16377    }
16378    function _iconDroplet(ctx, style) {
16379        var DropletShape = require('zrender/shape/Droplet');
16380        DropletShape.prototype.buildPath(ctx, {
16381            x: style.x + style.width * 0.5,
16382            y: style.y + style.height * 0.5,
16383            a: style.width * 0.5,
16384            b: style.height * 0.8
16385        });
16386    }
16387    function _iconPin(ctx, style) {
16388        var x = style.x;
16389        var y = style.y - style.height / 2 * 1.5;
16390        var width = style.width / 2;
16391        var height = style.height / 2;
16392        var r = Math.min(width, height);
16393        ctx.arc(x + width, y + height, r, Math.PI / 5 * 4, Math.PI / 5);
16394        ctx.lineTo(x + width, y + height + r * 1.5);
16395        ctx.closePath();
16396    }
16397    function _iconImage(ctx, style, refreshNextFrame) {
16398        var ImageShape = require('zrender/shape/Image');
16399        this._imageShape = this._imageShape || new ImageShape({ style: {} });
16400        for (var name in style) {
16401            this._imageShape.style[name] = style[name];
16402        }
16403        this._imageShape.brush(ctx, false, refreshNextFrame);
16404    }
16405    var Base = require('zrender/shape/Base');
16406    function Icon(options) {
16407        Base.call(this, options);
16408    }
16409    Icon.prototype = {
16410        type: 'icon',
16411        iconLibrary: {
16412            mark: _iconMark,
16413            markUndo: _iconMarkUndo,
16414            markClear: _iconMarkClear,
16415            dataZoom: _iconDataZoom,
16416            dataZoomReset: _iconDataZoomReset,
16417            restore: _iconRestore,
16418            lineChart: _iconLineChart,
16419            barChart: _iconBarChart,
16420            pieChart: _iconPieChart,
16421            funnelChart: _iconFunnelChart,
16422            forceChart: _iconForceChart,
16423            chordChart: _iconChordChart,
16424            stackChart: _iconStackChart,
16425            tiledChart: _iconTiledChart,
16426            dataView: _iconDataView,
16427            saveAsImage: _iconSave,
16428            cross: _iconCross,
16429            circle: _iconCircle,
16430            rectangle: _iconRectangle,
16431            triangle: _iconTriangle,
16432            diamond: _iconDiamond,
16433            arrow: _iconArrow,
16434            star: _iconStar,
16435            heart: _iconHeart,
16436            droplet: _iconDroplet,
16437            pin: _iconPin,
16438            image: _iconImage
16439        },
16440        brush: function (ctx, isHighlight, refreshNextFrame) {
16441            var style = isHighlight ? this.highlightStyle : this.style;
16442            style = style || {};
16443            var iconType = style.iconType || this.style.iconType;
16444            if (iconType === 'image') {
16445                var ImageShape = require('zrender/shape/Image');
16446                ImageShape.prototype.brush.call(this, ctx, isHighlight, refreshNextFrame);
16447            } else {
16448                var style = this.beforeBrush(ctx, isHighlight);
16449                ctx.beginPath();
16450                this.buildPath(ctx, style, refreshNextFrame);
16451                switch (style.brushType) {
16452                case 'both':
16453                    ctx.fill();
16454                case 'stroke':
16455                    style.lineWidth > 0 && ctx.stroke();
16456                    break;
16457                default:
16458                    ctx.fill();
16459                }
16460                this.drawText(ctx, style, this.style);
16461                this.afterBrush(ctx);
16462            }
16463        },
16464        buildPath: function (ctx, style, refreshNextFrame) {
16465            if (this.iconLibrary[style.iconType]) {
16466                this.iconLibrary[style.iconType].call(this, ctx, style, refreshNextFrame);
16467            } else {
16468                ctx.moveTo(style.x, style.y);
16469                ctx.lineTo(style.x + style.width, style.y);
16470                ctx.lineTo(style.x + style.width, style.y + style.height);
16471                ctx.lineTo(style.x, style.y + style.height);
16472                ctx.lineTo(style.x, style.y);
16473                ctx.closePath();
16474            }
16475            return;
16476        },
16477        getRect: function (style) {
16478            if (style.__rect) {
16479                return style.__rect;
16480            }
16481            style.__rect = {
16482                x: Math.round(style.x),
16483                y: Math.round(style.y - (style.iconType == 'pin' ? style.height / 2 * 1.5 : 0)),
16484                width: style.width,
16485                height: style.height * (style.iconType === 'pin' ? 1.25 : 1)
16486            };
16487            return style.__rect;
16488        },
16489        isCover: function (x, y) {
16490            var originPos = this.transformCoordToLocal(x, y);
16491            x = originPos[0];
16492            y = originPos[1];
16493            var rect = this.style.__rect;
16494            if (!rect) {
16495                rect = this.style.__rect = this.getRect(this.style);
16496            }
16497            var delta = rect.height < 8 || rect.width < 8 ? 4 : 0;
16498            return x >= rect.x - delta && x <= rect.x + rect.width + delta && y >= rect.y - delta && y <= rect.y + rect.height + delta;
16499        }
16500    };
16501    zrUtil.inherits(Icon, Base);
16502    return Icon;
16503});define('echarts/util/shape/MarkLine', [
16504    'require',
16505    'zrender/shape/Base',
16506    './Icon',
16507    'zrender/shape/Line',
16508    'zrender/shape/BezierCurve',
16509    'zrender/tool/area',
16510    'zrender/shape/util/dashedLineTo',
16511    'zrender/tool/util',
16512    'zrender/tool/curve'
16513], function (require) {
16514    var Base = require('zrender/shape/Base');
16515    var IconShape = require('./Icon');
16516    var LineShape = require('zrender/shape/Line');
16517    var lineInstance = new LineShape({});
16518    var CurveShape = require('zrender/shape/BezierCurve');
16519    var curveInstance = new CurveShape({});
16520    var area = require('zrender/tool/area');
16521    var dashedLineTo = require('zrender/shape/util/dashedLineTo');
16522    var zrUtil = require('zrender/tool/util');
16523    var curveTool = require('zrender/tool/curve');
16524    function MarkLine(options) {
16525        Base.call(this, options);
16526        if (this.style.curveness > 0) {
16527            this.updatePoints(this.style);
16528        }
16529        if (this.highlightStyle.curveness > 0) {
16530            this.updatePoints(this.highlightStyle);
16531        }
16532    }
16533    MarkLine.prototype = {
16534        type: 'mark-line',
16535        brush: function (ctx, isHighlight) {
16536            var style = this.style;
16537            if (isHighlight) {
16538                style = this.getHighlightStyle(style, this.highlightStyle || {});
16539            }
16540            ctx.save();
16541            this.setContext(ctx, style);
16542            this.setTransform(ctx);
16543            ctx.save();
16544            ctx.beginPath();
16545            this.buildPath(ctx, style);
16546            ctx.stroke();
16547            ctx.restore();
16548            this.brushSymbol(ctx, style, 0);
16549            this.brushSymbol(ctx, style, 1);
16550            this.drawText(ctx, style, this.style);
16551            ctx.restore();
16552        },
16553        buildPath: function (ctx, style) {
16554            var lineType = style.lineType || 'solid';
16555            ctx.moveTo(style.xStart, style.yStart);
16556            if (style.curveness > 0) {
16557                var lineDash = null;
16558                switch (lineType) {
16559                case 'dashed':
16560                    lineDash = [
16561                        5,
16562                        5
16563                    ];
16564                    break;
16565                case 'dotted':
16566                    lineDash = [
16567                        1,
16568                        1
16569                    ];
16570                    break;
16571                }
16572                if (lineDash && ctx.setLineDash) {
16573                    ctx.setLineDash(lineDash);
16574                }
16575                ctx.quadraticCurveTo(style.cpX1, style.cpY1, style.xEnd, style.yEnd);
16576            } else {
16577                if (lineType == 'solid') {
16578                    ctx.lineTo(style.xEnd, style.yEnd);
16579                } else {
16580                    var dashLength = (style.lineWidth || 1) * (style.lineType == 'dashed' ? 5 : 1);
16581                    dashedLineTo(ctx, style.xStart, style.yStart, style.xEnd, style.yEnd, dashLength);
16582                }
16583            }
16584        },
16585        updatePoints: function (style) {
16586            var curveness = style.curveness || 0;
16587            var inv = 1;
16588            var x0 = style.xStart;
16589            var y0 = style.yStart;
16590            var x2 = style.xEnd;
16591            var y2 = style.yEnd;
16592            var x1 = (x0 + x2) / 2 - inv * (y0 - y2) * curveness;
16593            var y1 = (y0 + y2) / 2 - inv * (x2 - x0) * curveness;
16594            style.cpX1 = x1;
16595            style.cpY1 = y1;
16596        },
16597        brushSymbol: function (ctx, style, idx) {
16598            if (style.symbol[idx] == 'none') {
16599                return;
16600            }
16601            ctx.save();
16602            ctx.beginPath();
16603            ctx.lineWidth = style.symbolBorder;
16604            ctx.strokeStyle = style.symbolBorderColor;
16605            var symbol = style.symbol[idx].replace('empty', '').toLowerCase();
16606            if (style.symbol[idx].match('empty')) {
16607                ctx.fillStyle = '#fff';
16608            }
16609            var x0 = style.xStart;
16610            var y0 = style.yStart;
16611            var x2 = style.xEnd;
16612            var y2 = style.yEnd;
16613            var x = idx === 0 ? x0 : x2;
16614            var y = idx === 0 ? y0 : y2;
16615            var curveness = style.curveness || 0;
16616            var rotate = style.symbolRotate[idx] != null ? style.symbolRotate[idx] - 0 : 0;
16617            rotate = rotate / 180 * Math.PI;
16618            if (symbol == 'arrow' && rotate === 0) {
16619                if (curveness === 0) {
16620                    var sign = idx === 0 ? -1 : 1;
16621                    rotate = Math.PI / 2 + Math.atan2(sign * (y2 - y0), sign * (x2 - x0));
16622                } else {
16623                    var x1 = style.cpX1;
16624                    var y1 = style.cpY1;
16625                    var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
16626                    var dx = quadraticDerivativeAt(x0, x1, x2, idx);
16627                    var dy = quadraticDerivativeAt(y0, y1, y2, idx);
16628                    rotate = Math.PI / 2 + Math.atan2(dy, dx);
16629                }
16630            }
16631            ctx.translate(x, y);
16632            if (rotate !== 0) {
16633                ctx.rotate(rotate);
16634            }
16635            var symbolSize = style.symbolSize[idx];
16636            IconShape.prototype.buildPath(ctx, {
16637                x: -symbolSize,
16638                y: -symbolSize,
16639                width: symbolSize * 2,
16640                height: symbolSize * 2,
16641                iconType: symbol
16642            });
16643            ctx.closePath();
16644            ctx.fill();
16645            ctx.stroke();
16646            ctx.restore();
16647        },
16648        getRect: function (style) {
16649            style.curveness > 0 ? curveInstance.getRect(style) : lineInstance.getRect(style);
16650            return style.__rect;
16651        },
16652        isCover: function (x, y) {
16653            var originPos = this.transformCoordToLocal(x, y);
16654            x = originPos[0];
16655            y = originPos[1];
16656            if (this.isCoverRect(x, y)) {
16657                return this.style.curveness > 0 ? area.isInside(curveInstance, this.style, x, y) : area.isInside(lineInstance, this.style, x, y);
16658            }
16659            return false;
16660        }
16661    };
16662    zrUtil.inherits(MarkLine, Base);
16663    return MarkLine;
16664});define('echarts/util/shape/Symbol', [
16665    'require',
16666    'zrender/shape/Base',
16667    'zrender/shape/Polygon',
16668    'zrender/tool/util',
16669    './normalIsCover'
16670], function (require) {
16671    var Base = require('zrender/shape/Base');
16672    var PolygonShape = require('zrender/shape/Polygon');
16673    var polygonInstance = new PolygonShape({});
16674    var zrUtil = require('zrender/tool/util');
16675    function Symbol(options) {
16676        Base.call(this, options);
16677    }
16678    Symbol.prototype = {
16679        type: 'symbol',
16680        buildPath: function (ctx, style) {
16681            var pointList = style.pointList;
16682            var len = pointList.length;
16683            if (len === 0) {
16684                return;
16685            }
16686            var subSize = 10000;
16687            var subSetLength = Math.ceil(len / subSize);
16688            var sub;
16689            var subLen;
16690            var isArray = pointList[0] instanceof Array;
16691            var size = style.size ? style.size : 2;
16692            var curSize = size;
16693            var halfSize = size / 2;
16694            var PI2 = Math.PI * 2;
16695            var percent;
16696            var x;
16697            var y;
16698            for (var j = 0; j < subSetLength; j++) {
16699                ctx.beginPath();
16700                sub = j * subSize;
16701                subLen = sub + subSize;
16702                subLen = subLen > len ? len : subLen;
16703                for (var i = sub; i < subLen; i++) {
16704                    if (style.random) {
16705                        percent = style['randomMap' + i % 20] / 100;
16706                        curSize = size * percent * percent;
16707                        halfSize = curSize / 2;
16708                    }
16709                    if (isArray) {
16710                        x = pointList[i][0];
16711                        y = pointList[i][1];
16712                    } else {
16713                        x = pointList[i].x;
16714                        y = pointList[i].y;
16715                    }
16716                    if (curSize < 3) {
16717                        ctx.rect(x - halfSize, y - halfSize, curSize, curSize);
16718                    } else {
16719                        switch (style.iconType) {
16720                        case 'circle':
16721                            ctx.moveTo(x, y);
16722                            ctx.arc(x, y, halfSize, 0, PI2, true);
16723                            break;
16724                        case 'diamond':
16725                            ctx.moveTo(x, y - halfSize);
16726                            ctx.lineTo(x + halfSize / 3, y - halfSize / 3);
16727                            ctx.lineTo(x + halfSize, y);
16728                            ctx.lineTo(x + halfSize / 3, y + halfSize / 3);
16729                            ctx.lineTo(x, y + halfSize);
16730                            ctx.lineTo(x - halfSize / 3, y + halfSize / 3);
16731                            ctx.lineTo(x - halfSize, y);
16732                            ctx.lineTo(x - halfSize / 3, y - halfSize / 3);
16733                            ctx.lineTo(x, y - halfSize);
16734                            break;
16735                        default:
16736                            ctx.rect(x - halfSize, y - halfSize, curSize, curSize);
16737                        }
16738                    }
16739                }
16740                ctx.closePath();
16741                if (j < subSetLength - 1) {
16742                    switch (style.brushType) {
16743                    case 'both':
16744                        ctx.fill();
16745                        style.lineWidth > 0 && ctx.stroke();
16746                        break;
16747                    case 'stroke':
16748                        style.lineWidth > 0 && ctx.stroke();
16749                        break;
16750                    default:
16751                        ctx.fill();
16752                    }
16753                }
16754            }
16755        },
16756        getRect: function (style) {
16757            return style.__rect || polygonInstance.getRect(style);
16758        },
16759        isCover: require('./normalIsCover')
16760    };
16761    zrUtil.inherits(Symbol, Base);
16762    return Symbol;
16763});define('zrender/shape/Polyline', [
16764    'require',
16765    './Base',
16766    './util/smoothSpline',
16767    './util/smoothBezier',
16768    './util/dashedLineTo',
16769    './Polygon',
16770    '../tool/util'
16771], function (require) {
16772    var Base = require('./Base');
16773    var smoothSpline = require('./util/smoothSpline');
16774    var smoothBezier = require('./util/smoothBezier');
16775    var dashedLineTo = require('./util/dashedLineTo');
16776    var Polyline = function (options) {
16777        this.brushTypeOnly = 'stroke';
16778        this.textPosition = 'end';
16779        Base.call(this, options);
16780    };
16781    Polyline.prototype = {
16782        type: 'polyline',
16783        buildPath: function (ctx, style) {
16784            var pointList = style.pointList;
16785            if (pointList.length < 2) {
16786                return;
16787            }
16788            var len = Math.min(style.pointList.length, Math.round(style.pointListLength || style.pointList.length));
16789            if (style.smooth && style.smooth !== 'spline') {
16790                if (!style.controlPointList) {
16791                    this.updateControlPoints(style);
16792                }
16793                var controlPointList = style.controlPointList;
16794                ctx.moveTo(pointList[0][0], pointList[0][1]);
16795                var cp1;
16796                var cp2;
16797                var p;
16798                for (var i = 0; i < len - 1; i++) {
16799                    cp1 = controlPointList[i * 2];
16800                    cp2 = controlPointList[i * 2 + 1];
16801                    p = pointList[i + 1];
16802                    ctx.bezierCurveTo(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]);
16803                }
16804            } else {
16805                if (style.smooth === 'spline') {
16806                    pointList = smoothSpline(pointList);
16807                    len = pointList.length;
16808                }
16809                if (!style.lineType || style.lineType == 'solid') {
16810                    ctx.moveTo(pointList[0][0], pointList[0][1]);
16811                    for (var i = 1; i < len; i++) {
16812                        ctx.lineTo(pointList[i][0], pointList[i][1]);
16813                    }
16814                } else if (style.lineType == 'dashed' || style.lineType == 'dotted') {
16815                    var dashLength = (style.lineWidth || 1) * (style.lineType == 'dashed' ? 5 : 1);
16816                    ctx.moveTo(pointList[0][0], pointList[0][1]);
16817                    for (var i = 1; i < len; i++) {
16818                        dashedLineTo(ctx, pointList[i - 1][0], pointList[i - 1][1], pointList[i][0], pointList[i][1], dashLength);
16819                    }
16820                }
16821            }
16822            return;
16823        },
16824        updateControlPoints: function (style) {
16825            style.controlPointList = smoothBezier(style.pointList, style.smooth, false, style.smoothConstraint);
16826        },
16827        getRect: function (style) {
16828            return require('./Polygon').prototype.getRect(style);
16829        }
16830    };
16831    require('../tool/util').inherits(Polyline, Base);
16832    return Polyline;
16833});define('zrender/shape/ShapeBundle', [
16834    'require',
16835    './Base',
16836    '../tool/util'
16837], function (require) {
16838    var Base = require('./Base');
16839    var ShapeBundle = function (options) {
16840        Base.call(this, options);
16841    };
16842    ShapeBundle.prototype = {
16843        constructor: ShapeBundle,
16844        type: 'shape-bundle',
16845        brush: function (ctx, isHighlight) {
16846            var style = this.beforeBrush(ctx, isHighlight);
16847            ctx.beginPath();
16848            for (var i = 0; i < style.shapeList.length; i++) {
16849                var subShape = style.shapeList[i];
16850                var subShapeStyle = subShape.style;
16851                if (isHighlight) {
16852                    subShapeStyle = subShape.getHighlightStyle(subShapeStyle, subShape.highlightStyle || {}, subShape.brushTypeOnly);
16853                }
16854                subShape.buildPath(ctx, subShapeStyle);
16855            }
16856            switch (style.brushType) {
16857            case 'both':
16858                ctx.fill();
16859            case 'stroke':
16860                style.lineWidth > 0 && ctx.stroke();
16861                break;
16862            default:
16863                ctx.fill();
16864            }
16865            this.drawText(ctx, style, this.style);
16866            this.afterBrush(ctx);
16867        },
16868        getRect: function (style) {
16869            if (style.__rect) {
16870                return style.__rect;
16871            }
16872            var minX = Infinity;
16873            var maxX = -Infinity;
16874            var minY = Infinity;
16875            var maxY = -Infinity;
16876            for (var i = 0; i < style.shapeList.length; i++) {
16877                var subShape = style.shapeList[i];
16878                var subRect = subShape.getRect(subShape.style);
16879                var minX = Math.min(subRect.x, minX);
16880                var minY = Math.min(subRect.y, minY);
16881                var maxX = Math.max(subRect.x + subRect.width, maxX);
16882                var maxY = Math.max(subRect.y + subRect.height, maxY);
16883            }
16884            style.__rect = {
16885                x: minX,
16886                y: minY,
16887                width: maxX - minX,
16888                height: maxY - minY
16889            };
16890            return style.__rect;
16891        },
16892        isCover: function (x, y) {
16893            var originPos = this.transformCoordToLocal(x, y);
16894            x = originPos[0];
16895            y = originPos[1];
16896            if (this.isCoverRect(x, y)) {
16897                for (var i = 0; i < this.style.shapeList.length; i++) {
16898                    var subShape = this.style.shapeList[i];
16899                    if (subShape.isCover(x, y)) {
16900                        return true;
16901                    }
16902                }
16903            }
16904            return false;
16905        }
16906    };
16907    require('../tool/util').inherits(ShapeBundle, Base);
16908    return ShapeBundle;
16909});define('echarts/util/ecAnimation', [
16910    'require',
16911    'zrender/tool/util',
16912    'zrender/tool/curve',
16913    'zrender/shape/Polygon'
16914], function (require) {
16915    var zrUtil = require('zrender/tool/util');
16916    var curveTool = require('zrender/tool/curve');
16917    function pointList(zr, oldShape, newShape, duration, easing) {
16918        var newPointList = newShape.style.pointList;
16919        var newPointListLen = newPointList.length;
16920        var oldPointList;
16921        if (!oldShape) {
16922            oldPointList = [];
16923            if (newShape._orient != 'vertical') {
16924                var y = newPointList[0][1];
16925                for (var i = 0; i < newPointListLen; i++) {
16926                    oldPointList[i] = [
16927                        newPointList[i][0],
16928                        y
16929                    ];
16930                }
16931            } else {
16932                var x = newPointList[0][0];
16933                for (var i = 0; i < newPointListLen; i++) {
16934                    oldPointList[i] = [
16935                        x,
16936                        newPointList[i][1]
16937                    ];
16938                }
16939            }
16940            if (newShape.type == 'half-smooth-polygon') {
16941                oldPointList[newPointListLen - 1] = zrUtil.clone(newPointList[newPointListLen - 1]);
16942                oldPointList[newPointListLen - 2] = zrUtil.clone(newPointList[newPointListLen - 2]);
16943            }
16944            oldShape = { style: { pointList: oldPointList } };
16945        }
16946        oldPointList = oldShape.style.pointList;
16947        var oldPointListLen = oldPointList.length;
16948        if (oldPointListLen == newPointListLen) {
16949            newShape.style.pointList = oldPointList;
16950        } else if (oldPointListLen < newPointListLen) {
16951            newShape.style.pointList = oldPointList.concat(newPointList.slice(oldPointListLen));
16952        } else {
16953            newShape.style.pointList = oldPointList.slice(0, newPointListLen);
16954        }
16955        zr.addShape(newShape);
16956        newShape.__animating = true;
16957        zr.animate(newShape.id, 'style').when(duration, { pointList: newPointList }).during(function () {
16958            if (newShape.updateControlPoints) {
16959                newShape.updateControlPoints(newShape.style);
16960            }
16961        }).done(function () {
16962            newShape.__animating = false;
16963        }).start(easing);
16964    }
16965    function cloneStyle(target, source) {
16966        var len = arguments.length;
16967        for (var i = 2; i < len; i++) {
16968            var prop = arguments[i];
16969            target.style[prop] = source.style[prop];
16970        }
16971    }
16972    function rectangle(zr, oldShape, newShape, duration, easing) {
16973        var newShapeStyle = newShape.style;
16974        if (!oldShape) {
16975            oldShape = {
16976                position: newShape.position,
16977                style: {
16978                    x: newShapeStyle.x,
16979                    y: newShape._orient == 'vertical' ? newShapeStyle.y + newShapeStyle.height : newShapeStyle.y,
16980                    width: newShape._orient == 'vertical' ? newShapeStyle.width : 0,
16981                    height: newShape._orient != 'vertical' ? newShapeStyle.height : 0
16982                }
16983            };
16984        }
16985        var newX = newShapeStyle.x;
16986        var newY = newShapeStyle.y;
16987        var newWidth = newShapeStyle.width;
16988        var newHeight = newShapeStyle.height;
16989        var newPosition = [
16990            newShape.position[0],
16991            newShape.position[1]
16992        ];
16993        cloneStyle(newShape, oldShape, 'x', 'y', 'width', 'height');
16994        newShape.position = oldShape.position;
16995        zr.addShape(newShape);
16996        if (newPosition[0] != oldShape.position[0] || newPosition[1] != oldShape.position[1]) {
16997            zr.animate(newShape.id, '').when(duration, { position: newPosition }).start(easing);
16998        }
16999        newShape.__animating = true;
17000        zr.animate(newShape.id, 'style').when(duration, {
17001            x: newX,
17002            y: newY,
17003            width: newWidth,
17004            height: newHeight
17005        }).done(function () {
17006            newShape.__animating = false;
17007        }).start(easing);
17008    }
17009    function candle(zr, oldShape, newShape, duration, easing) {
17010        if (!oldShape) {
17011            var y = newShape.style.y;
17012            oldShape = {
17013                style: {
17014                    y: [
17015                        y[0],
17016                        y[0],
17017                        y[0],
17018                        y[0]
17019                    ]
17020                }
17021            };
17022        }
17023        var newY = newShape.style.y;
17024        newShape.style.y = oldShape.style.y;
17025        zr.addShape(newShape);
17026        newShape.__animating = true;
17027        zr.animate(newShape.id, 'style').when(duration, { y: newY }).done(function () {
17028            newShape.__animating = false;
17029        }).start(easing);
17030    }
17031    function ring(zr, oldShape, newShape, duration, easing) {
17032        var x = newShape.style.x;
17033        var y = newShape.style.y;
17034        var r0 = newShape.style.r0;
17035        var r = newShape.style.r;
17036        newShape.__animating = true;
17037        if (newShape._animationAdd != 'r') {
17038            newShape.style.r0 = 0;
17039            newShape.style.r = 0;
17040            newShape.rotation = [
17041                Math.PI * 2,
17042                x,
17043                y
17044            ];
17045            zr.addShape(newShape);
17046            zr.animate(newShape.id, 'style').when(duration, {
17047                r0: r0,
17048                r: r
17049            }).done(function () {
17050                newShape.__animating = false;
17051            }).start(easing);
17052            zr.animate(newShape.id, '').when(duration, {
17053                rotation: [
17054                    0,
17055                    x,
17056                    y
17057                ]
17058            }).start(easing);
17059        } else {
17060            newShape.style.r0 = newShape.style.r;
17061            zr.addShape(newShape);
17062            zr.animate(newShape.id, 'style').when(duration, { r0: r0 }).done(function () {
17063                newShape.__animating = false;
17064            }).start(easing);
17065        }
17066    }
17067    function sector(zr, oldShape, newShape, duration, easing) {
17068        if (!oldShape) {
17069            if (newShape._animationAdd != 'r') {
17070                oldShape = {
17071                    style: {
17072                        startAngle: newShape.style.startAngle,
17073                        endAngle: newShape.style.startAngle
17074                    }
17075                };
17076            } else {
17077                oldShape = { style: { r0: newShape.style.r } };
17078            }
17079        }
17080        var startAngle = newShape.style.startAngle;
17081        var endAngle = newShape.style.endAngle;
17082        cloneStyle(newShape, oldShape, 'startAngle', 'endAngle');
17083        zr.addShape(newShape);
17084        newShape.__animating = true;
17085        zr.animate(newShape.id, 'style').when(duration, {
17086            startAngle: startAngle,
17087            endAngle: endAngle
17088        }).done(function () {
17089            newShape.__animating = false;
17090        }).start(easing);
17091    }
17092    function text(zr, oldShape, newShape, duration, easing) {
17093        if (!oldShape) {
17094            oldShape = {
17095                style: {
17096                    x: newShape.style.textAlign == 'left' ? newShape.style.x + 100 : newShape.style.x - 100,
17097                    y: newShape.style.y
17098                }
17099            };
17100        }
17101        var x = newShape.style.x;
17102        var y = newShape.style.y;
17103        cloneStyle(newShape, oldShape, 'x', 'y');
17104        zr.addShape(newShape);
17105        newShape.__animating = true;
17106        zr.animate(newShape.id, 'style').when(duration, {
17107            x: x,
17108            y: y
17109        }).done(function () {
17110            newShape.__animating = false;
17111        }).start(easing);
17112    }
17113    function polygon(zr, oldShape, newShape, duration, easing) {
17114        var rect = require('zrender/shape/Polygon').prototype.getRect(newShape.style);
17115        var x = rect.x + rect.width / 2;
17116        var y = rect.y + rect.height / 2;
17117        newShape.scale = [
17118            0.1,
17119            0.1,
17120            x,
17121            y
17122        ];
17123        zr.addShape(newShape);
17124        newShape.__animating = true;
17125        zr.animate(newShape.id, '').when(duration, {
17126            scale: [
17127                1,
17128                1,
17129                x,
17130                y
17131            ]
17132        }).done(function () {
17133            newShape.__animating = false;
17134        }).start(easing);
17135    }
17136    function ribbon(zr, oldShape, newShape, duration, easing) {
17137        if (!oldShape) {
17138            oldShape = {
17139                style: {
17140                    source0: 0,
17141                    source1: newShape.style.source1 > 0 ? 360 : -360,
17142                    target0: 0,
17143                    target1: newShape.style.target1 > 0 ? 360 : -360
17144                }
17145            };
17146        }
17147        var source0 = newShape.style.source0;
17148        var source1 = newShape.style.source1;
17149        var target0 = newShape.style.target0;
17150        var target1 = newShape.style.target1;
17151        if (oldShape.style) {
17152            cloneStyle(newShape, oldShape, 'source0', 'source1', 'target0', 'target1');
17153        }
17154        zr.addShape(newShape);
17155        newShape.__animating = true;
17156        zr.animate(newShape.id, 'style').when(duration, {
17157            source0: source0,
17158            source1: source1,
17159            target0: target0,
17160            target1: target1
17161        }).done(function () {
17162            newShape.__animating = false;
17163        }).start(easing);
17164    }
17165    function gaugePointer(zr, oldShape, newShape, duration, easing) {
17166        if (!oldShape) {
17167            oldShape = { style: { angle: newShape.style.startAngle } };
17168        }
17169        var angle = newShape.style.angle;
17170        newShape.style.angle = oldShape.style.angle;
17171        zr.addShape(newShape);
17172        newShape.__animating = true;
17173        zr.animate(newShape.id, 'style').when(duration, { angle: angle }).done(function () {
17174            newShape.__animating = false;
17175        }).start(easing);
17176    }
17177    function icon(zr, oldShape, newShape, duration, easing, delay) {
17178        newShape.style._x = newShape.style.x;
17179        newShape.style._y = newShape.style.y;
17180        newShape.style._width = newShape.style.width;
17181        newShape.style._height = newShape.style.height;
17182        if (!oldShape) {
17183            var x = newShape._x || 0;
17184            var y = newShape._y || 0;
17185            newShape.scale = [
17186                0.01,
17187                0.01,
17188                x,
17189                y
17190            ];
17191            zr.addShape(newShape);
17192            newShape.__animating = true;
17193            zr.animate(newShape.id, '').delay(delay).when(duration, {
17194                scale: [
17195                    1,
17196                    1,
17197                    x,
17198                    y
17199                ]
17200            }).done(function () {
17201                newShape.__animating = false;
17202            }).start(easing || 'QuinticOut');
17203        } else {
17204            rectangle(zr, oldShape, newShape, duration, easing);
17205        }
17206    }
17207    function line(zr, oldShape, newShape, duration, easing) {
17208        if (!oldShape) {
17209            oldShape = {
17210                style: {
17211                    xStart: newShape.style.xStart,
17212                    yStart: newShape.style.yStart,
17213                    xEnd: newShape.style.xStart,
17214                    yEnd: newShape.style.yStart
17215                }
17216            };
17217        }
17218        var xStart = newShape.style.xStart;
17219        var xEnd = newShape.style.xEnd;
17220        var yStart = newShape.style.yStart;
17221        var yEnd = newShape.style.yEnd;
17222        cloneStyle(newShape, oldShape, 'xStart', 'xEnd', 'yStart', 'yEnd');
17223        zr.addShape(newShape);
17224        newShape.__animating = true;
17225        zr.animate(newShape.id, 'style').when(duration, {
17226            xStart: xStart,
17227            xEnd: xEnd,
17228            yStart: yStart,
17229            yEnd: yEnd
17230        }).done(function () {
17231            newShape.__animating = false;
17232        }).start(easing);
17233    }
17234    function markline(zr, oldShape, newShape, duration, easing) {
17235        easing = easing || 'QuinticOut';
17236        newShape.__animating = true;
17237        zr.addShape(newShape);
17238        var newShapeStyle = newShape.style;
17239        var animationDone = function () {
17240            newShape.__animating = false;
17241        };
17242        var x0 = newShapeStyle.xStart;
17243        var y0 = newShapeStyle.yStart;
17244        var x2 = newShapeStyle.xEnd;
17245        var y2 = newShapeStyle.yEnd;
17246        if (newShapeStyle.curveness > 0) {
17247            newShape.updatePoints(newShapeStyle);
17248            var obj = { p: 0 };
17249            var x1 = newShapeStyle.cpX1;
17250            var y1 = newShapeStyle.cpY1;
17251            var newXArr = [];
17252            var newYArr = [];
17253            var subdivide = curveTool.quadraticSubdivide;
17254            zr.animation.animate(obj).when(duration, { p: 1 }).during(function () {
17255                subdivide(x0, x1, x2, obj.p, newXArr);
17256                subdivide(y0, y1, y2, obj.p, newYArr);
17257                newShapeStyle.cpX1 = newXArr[1];
17258                newShapeStyle.cpY1 = newYArr[1];
17259                newShapeStyle.xEnd = newXArr[2];
17260                newShapeStyle.yEnd = newYArr[2];
17261                zr.modShape(newShape);
17262            }).done(animationDone).start(easing);
17263        } else {
17264            zr.animate(newShape.id, 'style').when(0, {
17265                xEnd: x0,
17266                yEnd: y0
17267            }).when(duration, {
17268                xEnd: x2,
17269                yEnd: y2
17270            }).done(animationDone).start(easing);
17271        }
17272    }
17273    return {
17274        pointList: pointList,
17275        rectangle: rectangle,
17276        candle: candle,
17277        ring: ring,
17278        sector: sector,
17279        text: text,
17280        polygon: polygon,
17281        ribbon: ribbon,
17282        gaugePointer: gaugePointer,
17283        icon: icon,
17284        line: line,
17285        markline: markline
17286    };
17287});define('echarts/util/ecEffect', [
17288    'require',
17289    '../util/ecData',
17290    'zrender/shape/Circle',
17291    'zrender/shape/Image',
17292    'zrender/tool/curve',
17293    '../util/shape/Icon',
17294    '../util/shape/Symbol',
17295    'zrender/shape/ShapeBundle',
17296    'zrender/shape/Polyline',
17297    'zrender/tool/vector',
17298    'zrender/tool/env'
17299], function (require) {
17300    var ecData = require('../util/ecData');
17301    var CircleShape = require('zrender/shape/Circle');
17302    var ImageShape = require('zrender/shape/Image');
17303    var curveTool = require('zrender/tool/curve');
17304    var IconShape = require('../util/shape/Icon');
17305    var SymbolShape = require('../util/shape/Symbol');
17306    var ShapeBundle = require('zrender/shape/ShapeBundle');
17307    var Polyline = require('zrender/shape/Polyline');
17308    var vec2 = require('zrender/tool/vector');
17309    var canvasSupported = require('zrender/tool/env').canvasSupported;
17310    function point(zr, effectList, shape, zlevel) {
17311        var effect = shape.effect;
17312        var color = effect.color || shape.style.strokeColor || shape.style.color;
17313        var shadowColor = effect.shadowColor || color;
17314        var size = effect.scaleSize;
17315        var distance = effect.bounceDistance;
17316        var shadowBlur = typeof effect.shadowBlur != 'undefined' ? effect.shadowBlur : size;
17317        var effectShape;
17318        if (shape.type !== 'image') {
17319            effectShape = new IconShape({
17320                zlevel: zlevel,
17321                style: {
17322                    brushType: 'stroke',
17323                    iconType: shape.style.iconType != 'droplet' ? shape.style.iconType : 'circle',
17324                    x: shadowBlur + 1,
17325                    y: shadowBlur + 1,
17326                    n: shape.style.n,
17327                    width: shape.style._width * size,
17328                    height: shape.style._height * size,
17329                    lineWidth: 1,
17330                    strokeColor: color,
17331                    shadowColor: shadowColor,
17332                    shadowBlur: shadowBlur
17333                },
17334                draggable: false,
17335                hoverable: false
17336            });
17337            if (shape.style.iconType == 'pin') {
17338                effectShape.style.y += effectShape.style.height / 2 * 1.5;
17339            }
17340            if (canvasSupported) {
17341                effectShape.style.image = zr.shapeToImage(effectShape, effectShape.style.width + shadowBlur * 2 + 2, effectShape.style.height + shadowBlur * 2 + 2).style.image;
17342                effectShape = new ImageShape({
17343                    zlevel: effectShape.zlevel,
17344                    style: effectShape.style,
17345                    draggable: false,
17346                    hoverable: false
17347                });
17348            }
17349        } else {
17350            effectShape = new ImageShape({
17351                zlevel: zlevel,
17352                style: shape.style,
17353                draggable: false,
17354                hoverable: false
17355            });
17356        }
17357        ecData.clone(shape, effectShape);
17358        effectShape.position = shape.position;
17359        effectList.push(effectShape);
17360        zr.addShape(effectShape);
17361        var devicePixelRatio = shape.type !== 'image' ? window.devicePixelRatio || 1 : 1;
17362        var offset = (effectShape.style.width / devicePixelRatio - shape.style._width) / 2;
17363        effectShape.style.x = shape.style._x - offset;
17364        effectShape.style.y = shape.style._y - offset;
17365        if (shape.style.iconType == 'pin') {
17366            effectShape.style.y -= shape.style.height / 2 * 1.5;
17367        }
17368        var duration = (effect.period + Math.random() * 10) * 100;
17369        zr.modShape(shape.id, { invisible: true });
17370        var centerX = effectShape.style.x + effectShape.style.width / 2 / devicePixelRatio;
17371        var centerY = effectShape.style.y + effectShape.style.height / 2 / devicePixelRatio;
17372        if (effect.type === 'scale') {
17373            zr.modShape(effectShape.id, {
17374                scale: [
17375                    0.1,
17376                    0.1,
17377                    centerX,
17378                    centerY
17379                ]
17380            });
17381            zr.animate(effectShape.id, '', effect.loop).when(duration, {
17382                scale: [
17383                    1,
17384                    1,
17385                    centerX,
17386                    centerY
17387                ]
17388            }).done(function () {
17389                shape.effect.show = false;
17390                zr.delShape(effectShape.id);
17391            }).start();
17392        } else {
17393            zr.animate(effectShape.id, 'style', effect.loop).when(duration, { y: effectShape.style.y - distance }).when(duration * 2, { y: effectShape.style.y }).done(function () {
17394                shape.effect.show = false;
17395                zr.delShape(effectShape.id);
17396            }).start();
17397        }
17398    }
17399    function largePoint(zr, effectList, shape, zlevel) {
17400        var effect = shape.effect;
17401        var color = effect.color || shape.style.strokeColor || shape.style.color;
17402        var size = effect.scaleSize;
17403        var shadowColor = effect.shadowColor || color;
17404        var shadowBlur = typeof effect.shadowBlur != 'undefined' ? effect.shadowBlur : size * 2;
17405        var devicePixelRatio = window.devicePixelRatio || 1;
17406        var effectShape = new SymbolShape({
17407            zlevel: zlevel,
17408            position: shape.position,
17409            scale: shape.scale,
17410            style: {
17411                pointList: shape.style.pointList,
17412                iconType: shape.style.iconType,
17413                color: color,
17414                strokeColor: color,
17415                shadowColor: shadowColor,
17416                shadowBlur: shadowBlur * devicePixelRatio,
17417                random: true,
17418                brushType: 'fill',
17419                lineWidth: 1,
17420                size: shape.style.size
17421            },
17422            draggable: false,
17423            hoverable: false
17424        });
17425        effectList.push(effectShape);
17426        zr.addShape(effectShape);
17427        zr.modShape(shape.id, { invisible: true });
17428        var duration = Math.round(effect.period * 100);
17429        var clip1 = {};
17430        var clip2 = {};
17431        for (var i = 0; i < 20; i++) {
17432            effectShape.style['randomMap' + i] = 0;
17433            clip1 = {};
17434            clip1['randomMap' + i] = 100;
17435            clip2 = {};
17436            clip2['randomMap' + i] = 0;
17437            effectShape.style['randomMap' + i] = Math.random() * 100;
17438            zr.animate(effectShape.id, 'style', true).when(duration, clip1).when(duration * 2, clip2).when(duration * 3, clip1).when(duration * 4, clip1).delay(Math.random() * duration * i).start();
17439        }
17440    }
17441    function line(zr, effectList, shape, zlevel, isLarge) {
17442        var effect = shape.effect;
17443        var shapeStyle = shape.style;
17444        var color = effect.color || shapeStyle.strokeColor || shapeStyle.color;
17445        var shadowColor = effect.shadowColor || shapeStyle.strokeColor || color;
17446        var size = shapeStyle.lineWidth * effect.scaleSize;
17447        var shadowBlur = typeof effect.shadowBlur != 'undefined' ? effect.shadowBlur : size;
17448        var effectShape = new CircleShape({
17449            zlevel: zlevel,
17450            style: {
17451                x: shadowBlur,
17452                y: shadowBlur,
17453                r: size,
17454                color: color,
17455                shadowColor: shadowColor,
17456                shadowBlur: shadowBlur
17457            },
17458            hoverable: false
17459        });
17460        var offset = 0;
17461        if (canvasSupported && !isLarge) {
17462            var zlevel = effectShape.zlevel;
17463            effectShape = zr.shapeToImage(effectShape, (size + shadowBlur) * 2, (size + shadowBlur) * 2);
17464            effectShape.zlevel = zlevel;
17465            effectShape.hoverable = false;
17466            offset = shadowBlur;
17467        }
17468        if (!isLarge) {
17469            ecData.clone(shape, effectShape);
17470            effectShape.position = shape.position;
17471            effectList.push(effectShape);
17472            zr.addShape(effectShape);
17473        }
17474        var effectDone = function () {
17475            if (!isLarge) {
17476                shape.effect.show = false;
17477                zr.delShape(effectShape.id);
17478            }
17479            effectShape.effectAnimator = null;
17480        };
17481        if (shape instanceof Polyline) {
17482            var distanceList = [0];
17483            var totalDist = 0;
17484            var pointList = shapeStyle.pointList;
17485            var controlPointList = shapeStyle.controlPointList;
17486            for (var i = 1; i < pointList.length; i++) {
17487                if (controlPointList) {
17488                    var cp1 = controlPointList[(i - 1) * 2];
17489                    var cp2 = controlPointList[(i - 1) * 2 + 1];
17490                    totalDist += vec2.dist(pointList[i - 1], cp1) + vec2.dist(cp1, cp2) + vec2.dist(cp2, pointList[i]);
17491                } else {
17492                    totalDist += vec2.dist(pointList[i - 1], pointList[i]);
17493                }
17494                distanceList.push(totalDist);
17495            }
17496            var obj = { p: 0 };
17497            var animator = zr.animation.animate(obj, { loop: effect.loop });
17498            for (var i = 0; i < distanceList.length; i++) {
17499                animator.when(distanceList[i] * effect.period, { p: i });
17500            }
17501            animator.during(function () {
17502                var i = Math.floor(obj.p);
17503                var x, y;
17504                if (i == pointList.length - 1) {
17505                    x = pointList[i][0];
17506                    y = pointList[i][1];
17507                } else {
17508                    var t = obj.p - i;
17509                    var p0 = pointList[i];
17510                    var p1 = pointList[i + 1];
17511                    if (controlPointList) {
17512                        var cp1 = controlPointList[i * 2];
17513                        var cp2 = controlPointList[i * 2 + 1];
17514                        x = curveTool.cubicAt(p0[0], cp1[0], cp2[0], p1[0], t);
17515                        y = curveTool.cubicAt(p0[1], cp1[1], cp2[1], p1[1], t);
17516                    } else {
17517                        x = (p1[0] - p0[0]) * t + p0[0];
17518                        y = (p1[1] - p0[1]) * t + p0[1];
17519                    }
17520                }
17521                effectShape.style.x = x;
17522                effectShape.style.y = y;
17523                if (!isLarge) {
17524                    zr.modShape(effectShape);
17525                }
17526            }).done(effectDone).start();
17527            animator.duration = totalDist * effect.period;
17528            effectShape.effectAnimator = animator;
17529        } else {
17530            var x0 = shapeStyle.xStart - offset;
17531            var y0 = shapeStyle.yStart - offset;
17532            var x2 = shapeStyle.xEnd - offset;
17533            var y2 = shapeStyle.yEnd - offset;
17534            effectShape.style.x = x0;
17535            effectShape.style.y = y0;
17536            var distance = (x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0);
17537            var duration = Math.round(Math.sqrt(Math.round(distance * effect.period * effect.period)));
17538            if (shape.style.curveness > 0) {
17539                var x1 = shapeStyle.cpX1 - offset;
17540                var y1 = shapeStyle.cpY1 - offset;
17541                effectShape.effectAnimator = zr.animation.animate(effectShape, { loop: effect.loop }).when(duration, { p: 1 }).during(function (target, t) {
17542                    effectShape.style.x = curveTool.quadraticAt(x0, x1, x2, t);
17543                    effectShape.style.y = curveTool.quadraticAt(y0, y1, y2, t);
17544                    if (!isLarge) {
17545                        zr.modShape(effectShape);
17546                    }
17547                }).done(effectDone).start();
17548            } else {
17549                effectShape.effectAnimator = zr.animation.animate(effectShape.style, { loop: effect.loop }).when(duration, {
17550                    x: x2,
17551                    y: y2
17552                }).during(function () {
17553                    if (!isLarge) {
17554                        zr.modShape(effectShape);
17555                    }
17556                }).done(effectDone).start();
17557            }
17558            effectShape.effectAnimator.duration = duration;
17559        }
17560        return effectShape;
17561    }
17562    function largeLine(zr, effectList, shape, zlevel) {
17563        var effectShape = new ShapeBundle({
17564            style: { shapeList: [] },
17565            zlevel: zlevel,
17566            hoverable: false
17567        });
17568        var shapeList = shape.style.shapeList;
17569        var effect = shape.effect;
17570        effectShape.position = shape.position;
17571        var maxDuration = 0;
17572        var subEffectAnimators = [];
17573        for (var i = 0; i < shapeList.length; i++) {
17574            shapeList[i].effect = effect;
17575            var subEffectShape = line(zr, null, shapeList[i], zlevel, true);
17576            var subEffectAnimator = subEffectShape.effectAnimator;
17577            effectShape.style.shapeList.push(subEffectShape);
17578            if (subEffectAnimator.duration > maxDuration) {
17579                maxDuration = subEffectAnimator.duration;
17580            }
17581            if (i === 0) {
17582                effectShape.style.color = subEffectShape.style.color;
17583                effectShape.style.shadowBlur = subEffectShape.style.shadowBlur;
17584                effectShape.style.shadowColor = subEffectShape.style.shadowColor;
17585            }
17586            subEffectAnimators.push(subEffectAnimator);
17587        }
17588        effectList.push(effectShape);
17589        zr.addShape(effectShape);
17590        var clearAllAnimators = function () {
17591            for (var i = 0; i < subEffectAnimators.length; i++) {
17592                subEffectAnimators[i].stop();
17593            }
17594        };
17595        if (maxDuration) {
17596            effectShape.__dummy = 0;
17597            var animator = zr.animate(effectShape.id, '', effect.loop).when(maxDuration, { __dummy: 1 }).during(function () {
17598                zr.modShape(effectShape);
17599            }).done(function () {
17600                shape.effect.show = false;
17601                zr.delShape(effectShape.id);
17602            }).start();
17603            var oldStop = animator.stop;
17604            animator.stop = function () {
17605                clearAllAnimators();
17606                oldStop.call(this);
17607            };
17608        }
17609    }
17610    return {
17611        point: point,
17612        largePoint: largePoint,
17613        line: line,
17614        largeLine: largeLine
17615    };
17616});define('echarts/component/base', [
17617    'require',
17618    '../config',
17619    '../util/ecData',
17620    '../util/ecQuery',
17621    '../util/number',
17622    'zrender/tool/util',
17623    'zrender/tool/env'
17624], function (require) {
17625    var ecConfig = require('../config');
17626    var ecData = require('../util/ecData');
17627    var ecQuery = require('../util/ecQuery');
17628    var number = require('../util/number');
17629    var zrUtil = require('zrender/tool/util');
17630    function Base(ecTheme, messageCenter, zr, option, myChart) {
17631        this.ecTheme = ecTheme;
17632        this.messageCenter = messageCenter;
17633        this.zr = zr;
17634        this.option = option;
17635        this.series = option.series;
17636        this.myChart = myChart;
17637        this.component = myChart.component;
17638        this.shapeList = [];
17639        this.effectList = [];
17640        var self = this;
17641        self._onlegendhoverlink = function (param) {
17642            if (self.legendHoverLink) {
17643                var targetName = param.target;
17644                var name;
17645                for (var i = self.shapeList.length - 1; i >= 0; i--) {
17646                    name = self.type == ecConfig.CHART_TYPE_PIE || self.type == ecConfig.CHART_TYPE_FUNNEL ? ecData.get(self.shapeList[i], 'name') : (ecData.get(self.shapeList[i], 'series') || {}).name;
17647                    if (name == targetName && !self.shapeList[i].invisible && !self.shapeList[i].__animating) {
17648                        self.zr.addHoverShape(self.shapeList[i]);
17649                    }
17650                }
17651            }
17652        };
17653        messageCenter && messageCenter.bind(ecConfig.EVENT.LEGEND_HOVERLINK, this._onlegendhoverlink);
17654    }
17655    Base.prototype = {
17656        canvasSupported: require('zrender/tool/env').canvasSupported,
17657        _getZ: function (zWhat) {
17658            if (this[zWhat] != null) {
17659                return this[zWhat];
17660            }
17661            var opt = this.ecTheme[this.type];
17662            if (opt && opt[zWhat] != null) {
17663                return opt[zWhat];
17664            }
17665            opt = ecConfig[this.type];
17666            if (opt && opt[zWhat] != null) {
17667                return opt[zWhat];
17668            }
17669            return 0;
17670        },
17671        getZlevelBase: function () {
17672            return this._getZ('zlevel');
17673        },
17674        getZBase: function () {
17675            return this._getZ('z');
17676        },
17677        reformOption: function (opt) {
17678            opt = zrUtil.merge(zrUtil.merge(opt || {}, zrUtil.clone(this.ecTheme[this.type] || {})), zrUtil.clone(ecConfig[this.type] || {}));
17679            this.z = opt.z;
17680            this.zlevel = opt.zlevel;
17681            return opt;
17682        },
17683        reformCssArray: function (p) {
17684            if (p instanceof Array) {
17685                switch (p.length + '') {
17686                case '4':
17687                    return p;
17688                case '3':
17689                    return [
17690                        p[0],
17691                        p[1],
17692                        p[2],
17693                        p[1]
17694                    ];
17695                case '2':
17696                    return [
17697                        p[0],
17698                        p[1],
17699                        p[0],
17700                        p[1]
17701                    ];
17702                case '1':
17703                    return [
17704                        p[0],
17705                        p[0],
17706                        p[0],
17707                        p[0]
17708                    ];
17709                case '0':
17710                    return [
17711                        0,
17712                        0,
17713                        0,
17714                        0
17715                    ];
17716                }
17717            } else {
17718                return [
17719                    p,
17720                    p,
17721                    p,
17722                    p
17723                ];
17724            }
17725        },
17726        getShapeById: function (id) {
17727            for (var i = 0, l = this.shapeList.length; i < l; i++) {
17728                if (this.shapeList[i].id === id) {
17729                    return this.shapeList[i];
17730                }
17731            }
17732            return null;
17733        },
17734        getFont: function (textStyle) {
17735            var finalTextStyle = this.getTextStyle(zrUtil.clone(textStyle));
17736            return finalTextStyle.fontStyle + ' ' + finalTextStyle.fontWeight + ' ' + finalTextStyle.fontSize + 'px ' + finalTextStyle.fontFamily;
17737        },
17738        getTextStyle: function (targetStyle) {
17739            return zrUtil.merge(zrUtil.merge(targetStyle || {}, this.ecTheme.textStyle), ecConfig.textStyle);
17740        },
17741        getItemStyleColor: function (itemColor, seriesIndex, dataIndex, data) {
17742            return typeof itemColor === 'function' ? itemColor.call(this.myChart, {
17743                seriesIndex: seriesIndex,
17744                series: this.series[seriesIndex],
17745                dataIndex: dataIndex,
17746                data: data
17747            }) : itemColor;
17748        },
17749        getDataFromOption: function (data, defaultData) {
17750            return data != null ? data.value != null ? data.value : data : defaultData;
17751        },
17752        subPixelOptimize: function (position, lineWidth) {
17753            if (lineWidth % 2 === 1) {
17754                position = Math.floor(position) + 0.5;
17755            } else {
17756                position = Math.round(position);
17757            }
17758            return position;
17759        },
17760        resize: function () {
17761            this.refresh && this.refresh();
17762            this.clearEffectShape && this.clearEffectShape(true);
17763            var self = this;
17764            setTimeout(function () {
17765                self.animationEffect && self.animationEffect();
17766            }, 200);
17767        },
17768        clear: function () {
17769            this.clearEffectShape && this.clearEffectShape();
17770            this.zr && this.zr.delShape(this.shapeList);
17771            this.shapeList = [];
17772        },
17773        dispose: function () {
17774            this.onbeforDispose && this.onbeforDispose();
17775            this.clear();
17776            this.shapeList = null;
17777            this.effectList = null;
17778            this.messageCenter && this.messageCenter.unbind(ecConfig.EVENT.LEGEND_HOVERLINK, this._onlegendhoverlink);
17779            this.onafterDispose && this.onafterDispose();
17780        },
17781        query: ecQuery.query,
17782        deepQuery: ecQuery.deepQuery,
17783        deepMerge: ecQuery.deepMerge,
17784        parsePercent: number.parsePercent,
17785        parseCenter: number.parseCenter,
17786        parseRadius: number.parseRadius,
17787        numAddCommas: number.addCommas,
17788        getPrecision: number.getPrecision
17789    };
17790    return Base;
17791});define('echarts/layout/EdgeBundling', [
17792    'require',
17793    '../data/KDTree',
17794    'zrender/tool/vector'
17795], function (require) {
17796    var KDTree = require('../data/KDTree');
17797    var vec2 = require('zrender/tool/vector');
17798    var v2Create = vec2.create;
17799    var v2DistSquare = vec2.distSquare;
17800    var v2Dist = vec2.dist;
17801    var v2Copy = vec2.copy;
17802    var v2Clone = vec2.clone;
17803    function squaredDistance(a, b) {
17804        a = a.array;
17805        b = b.array;
17806        var x = b[0] - a[0];
17807        var y = b[1] - a[1];
17808        var z = b[2] - a[2];
17809        var w = b[3] - a[3];
17810        return x * x + y * y + z * z + w * w;
17811    }
17812    function CoarsenedEdge(group) {
17813        this.points = [
17814            group.mp0,
17815            group.mp1
17816        ];
17817        this.group = group;
17818    }
17819    function Edge(edge) {
17820        var points = edge.points;
17821        if (points[0][1] < points[1][1] || edge instanceof CoarsenedEdge) {
17822            this.array = [
17823                points[0][0],
17824                points[0][1],
17825                points[1][0],
17826                points[1][1]
17827            ];
17828            this._startPoint = points[0];
17829            this._endPoint = points[1];
17830        } else {
17831            this.array = [
17832                points[1][0],
17833                points[1][1],
17834                points[0][0],
17835                points[0][1]
17836            ];
17837            this._startPoint = points[1];
17838            this._endPoint = points[0];
17839        }
17840        this.ink = v2Dist(points[0], points[1]);
17841        this.edge = edge;
17842        this.group = null;
17843    }
17844    Edge.prototype.getStartPoint = function () {
17845        return this._startPoint;
17846    };
17847    Edge.prototype.getEndPoint = function () {
17848        return this._endPoint;
17849    };
17850    function BundledEdgeGroup() {
17851        this.edgeList = [];
17852        this.mp0 = v2Create();
17853        this.mp1 = v2Create();
17854        this.ink = 0;
17855    }
17856    BundledEdgeGroup.prototype.addEdge = function (edge) {
17857        edge.group = this;
17858        this.edgeList.push(edge);
17859    };
17860    BundledEdgeGroup.prototype.removeEdge = function (edge) {
17861        edge.group = null;
17862        this.edgeList.splice(this.edgeList.indexOf(edge), 1);
17863    };
17864    function EdgeBundling() {
17865        this.maxNearestEdge = 6;
17866        this.maxTurningAngle = Math.PI / 4;
17867        this.maxIteration = 20;
17868    }
17869    EdgeBundling.prototype = {
17870        constructor: EdgeBundling,
17871        run: function (rawEdges) {
17872            var res = this._iterate(rawEdges);
17873            var nIterate = 0;
17874            while (nIterate++ < this.maxIteration) {
17875                var coarsenedEdges = [];
17876                for (var i = 0; i < res.groups.length; i++) {
17877                    coarsenedEdges.push(new CoarsenedEdge(res.groups[i]));
17878                }
17879                var newRes = this._iterate(coarsenedEdges);
17880                if (newRes.savedInk <= 0) {
17881                    break;
17882                } else {
17883                    res = newRes;
17884                }
17885            }
17886            var newEdges = [];
17887            function pointApproxEqual(p0, p1) {
17888                return v2DistSquare(p0, p1) < 1e-10;
17889            }
17890            function cleanEdgePoints(edgePoints, rawEdgePoints) {
17891                var res = [];
17892                var off = 0;
17893                for (var i = 0; i < edgePoints.length; i++) {
17894                    if (!(off > 0 && pointApproxEqual(edgePoints[i], res[off - 1]))) {
17895                        res[off++] = v2Clone(edgePoints[i]);
17896                    }
17897                }
17898                if (rawEdgePoints[0] && !pointApproxEqual(res[0], rawEdgePoints[0])) {
17899                    res = res.reverse();
17900                }
17901                return res;
17902            }
17903            var buildNewEdges = function (groups, fromEdgePoints) {
17904                var newEdgePoints;
17905                for (var i = 0; i < groups.length; i++) {
17906                    var group = groups[i];
17907                    if (group.edgeList[0] && group.edgeList[0].edge instanceof CoarsenedEdge) {
17908                        var newGroups = [];
17909                        for (var j = 0; j < group.edgeList.length; j++) {
17910                            newGroups.push(group.edgeList[j].edge.group);
17911                        }
17912                        if (!fromEdgePoints) {
17913                            newEdgePoints = [];
17914                        } else {
17915                            newEdgePoints = fromEdgePoints.slice();
17916                        }
17917                        newEdgePoints.unshift(group.mp0);
17918                        newEdgePoints.push(group.mp1);
17919                        buildNewEdges(newGroups, newEdgePoints);
17920                    } else {
17921                        for (var j = 0; j < group.edgeList.length; j++) {
17922                            var edge = group.edgeList[j];
17923                            if (!fromEdgePoints) {
17924                                newEdgePoints = [];
17925                            } else {
17926                                newEdgePoints = fromEdgePoints.slice();
17927                            }
17928                            newEdgePoints.unshift(group.mp0);
17929                            newEdgePoints.push(group.mp1);
17930                            newEdgePoints.unshift(edge.getStartPoint());
17931                            newEdgePoints.push(edge.getEndPoint());
17932                            newEdges.push({
17933                                points: cleanEdgePoints(newEdgePoints, edge.edge.points),
17934                                rawEdge: edge.edge
17935                            });
17936                        }
17937                    }
17938                }
17939            };
17940            buildNewEdges(res.groups);
17941            return newEdges;
17942        },
17943        _iterate: function (rawEdges) {
17944            var edges = [];
17945            var groups = [];
17946            var totalSavedInk = 0;
17947            for (var i = 0; i < rawEdges.length; i++) {
17948                var edge = new Edge(rawEdges[i]);
17949                edges.push(edge);
17950            }
17951            var tree = new KDTree(edges, 4);
17952            var nearests = [];
17953            var _mp0 = v2Create();
17954            var _mp1 = v2Create();
17955            var _newGroupInk = 0;
17956            var mp0 = v2Create();
17957            var mp1 = v2Create();
17958            var newGroupInk = 0;
17959            for (var i = 0; i < edges.length; i++) {
17960                var edge = edges[i];
17961                if (edge.group) {
17962                    continue;
17963                }
17964                tree.nearestN(edge, this.maxNearestEdge, squaredDistance, nearests);
17965                var maxSavedInk = 0;
17966                var mostSavingInkEdge = null;
17967                var lastCheckedGroup = null;
17968                for (var j = 0; j < nearests.length; j++) {
17969                    var nearest = nearests[j];
17970                    var savedInk = 0;
17971                    if (nearest.group) {
17972                        if (nearest.group !== lastCheckedGroup) {
17973                            lastCheckedGroup = nearest.group;
17974                            _newGroupInk = this._calculateGroupEdgeInk(nearest.group, edge, _mp0, _mp1);
17975                            savedInk = nearest.group.ink + edge.ink - _newGroupInk;
17976                        }
17977                    } else {
17978                        _newGroupInk = this._calculateEdgeEdgeInk(edge, nearest, _mp0, _mp1);
17979                        savedInk = nearest.ink + edge.ink - _newGroupInk;
17980                    }
17981                    if (savedInk > maxSavedInk) {
17982                        maxSavedInk = savedInk;
17983                        mostSavingInkEdge = nearest;
17984                        v2Copy(mp1, _mp1);
17985                        v2Copy(mp0, _mp0);
17986                        newGroupInk = _newGroupInk;
17987                    }
17988                }
17989                if (mostSavingInkEdge) {
17990                    totalSavedInk += maxSavedInk;
17991                    var group;
17992                    if (!mostSavingInkEdge.group) {
17993                        group = new BundledEdgeGroup();
17994                        groups.push(group);
17995                        group.addEdge(mostSavingInkEdge);
17996                    }
17997                    group = mostSavingInkEdge.group;
17998                    v2Copy(group.mp0, mp0);
17999                    v2Copy(group.mp1, mp1);
18000                    group.ink = newGroupInk;
18001                    mostSavingInkEdge.group.addEdge(edge);
18002                } else {
18003                    var group = new BundledEdgeGroup();
18004                    groups.push(group);
18005                    v2Copy(group.mp0, edge.getStartPoint());
18006                    v2Copy(group.mp1, edge.getEndPoint());
18007                    group.ink = edge.ink;
18008                    group.addEdge(edge);
18009                }
18010            }
18011            return {
18012                groups: groups,
18013                edges: edges,
18014                savedInk: totalSavedInk
18015            };
18016        },
18017        _calculateEdgeEdgeInk: function () {
18018            var startPointSet = [];
18019            var endPointSet = [];
18020            return function (e0, e1, mp0, mp1) {
18021                startPointSet[0] = e0.getStartPoint();
18022                startPointSet[1] = e1.getStartPoint();
18023                endPointSet[0] = e0.getEndPoint();
18024                endPointSet[1] = e1.getEndPoint();
18025                this._calculateMeetPoints(startPointSet, endPointSet, mp0, mp1);
18026                var ink = v2Dist(startPointSet[0], mp0) + v2Dist(mp0, mp1) + v2Dist(mp1, endPointSet[0]) + v2Dist(startPointSet[1], mp0) + v2Dist(mp1, endPointSet[1]);
18027                return ink;
18028            };
18029        }(),
18030        _calculateGroupEdgeInk: function (group, edgeTryAdd, mp0, mp1) {
18031            var startPointSet = [];
18032            var endPointSet = [];
18033            for (var i = 0; i < group.edgeList.length; i++) {
18034                var edge = group.edgeList[i];
18035                startPointSet.push(edge.getStartPoint());
18036                endPointSet.push(edge.getEndPoint());
18037            }
18038            startPointSet.push(edgeTryAdd.getStartPoint());
18039            endPointSet.push(edgeTryAdd.getEndPoint());
18040            this._calculateMeetPoints(startPointSet, endPointSet, mp0, mp1);
18041            var ink = v2Dist(mp0, mp1);
18042            for (var i = 0; i < startPointSet.length; i++) {
18043                ink += v2Dist(startPointSet[i], mp0) + v2Dist(endPointSet[i], mp1);
18044            }
18045            return ink;
18046        },
18047        _calculateMeetPoints: function () {
18048            var cp0 = v2Create();
18049            var cp1 = v2Create();
18050            return function (startPointSet, endPointSet, mp0, mp1) {
18051                vec2.set(cp0, 0, 0);
18052                vec2.set(cp1, 0, 0);
18053                var len = startPointSet.length;
18054                for (var i = 0; i < len; i++) {
18055                    vec2.add(cp0, cp0, startPointSet[i]);
18056                }
18057                vec2.scale(cp0, cp0, 1 / len);
18058                len = endPointSet.length;
18059                for (var i = 0; i < len; i++) {
18060                    vec2.add(cp1, cp1, endPointSet[i]);
18061                }
18062                vec2.scale(cp1, cp1, 1 / len);
18063                this._limitTurningAngle(startPointSet, cp0, cp1, mp0);
18064                this._limitTurningAngle(endPointSet, cp1, cp0, mp1);
18065            };
18066        }(),
18067        _limitTurningAngle: function () {
18068            var v10 = v2Create();
18069            var vTmp = v2Create();
18070            var project = v2Create();
18071            var tmpOut = v2Create();
18072            return function (pointSet, p0, p1, out) {
18073                var maxTurningAngleCos = Math.cos(this.maxTurningAngle);
18074                var maxTurningAngleTan = Math.tan(this.maxTurningAngle);
18075                vec2.sub(v10, p0, p1);
18076                vec2.normalize(v10, v10);
18077                vec2.copy(out, p0);
18078                var maxMovement = 0;
18079                for (var i = 0; i < pointSet.length; i++) {
18080                    var p = pointSet[i];
18081                    vec2.sub(vTmp, p, p0);
18082                    var len = vec2.len(vTmp);
18083                    vec2.scale(vTmp, vTmp, 1 / len);
18084                    var turningAngleCos = vec2.dot(vTmp, v10);
18085                    if (turningAngleCos < maxTurningAngleCos) {
18086                        vec2.scaleAndAdd(project, p0, v10, len * turningAngleCos);
18087                        var distance = v2Dist(project, p);
18088                        var d = distance / maxTurningAngleTan;
18089                        vec2.scaleAndAdd(tmpOut, project, v10, -d);
18090                        var movement = v2DistSquare(tmpOut, p0);
18091                        if (movement > maxMovement) {
18092                            maxMovement = movement;
18093                            vec2.copy(out, tmpOut);
18094                        }
18095                    }
18096                }
18097            };
18098        }()
18099    };
18100    return EdgeBundling;
18101});define('zrender/shape/Star', [
18102    'require',
18103    '../tool/math',
18104    './Base',
18105    '../tool/util'
18106], function (require) {
18107    var math = require('../tool/math');
18108    var sin = math.sin;
18109    var cos = math.cos;
18110    var PI = Math.PI;
18111    var Base = require('./Base');
18112    var Star = function (options) {
18113        Base.call(this, options);
18114    };
18115    Star.prototype = {
18116        type: 'star',
18117        buildPath: function (ctx, style) {
18118            var n = style.n;
18119            if (!n || n < 2) {
18120                return;
18121            }
18122            var x = style.x;
18123            var y = style.y;
18124            var r = style.r;
18125            var r0 = style.r0;
18126            if (r0 == null) {
18127                r0 = n > 4 ? r * cos(2 * PI / n) / cos(PI / n) : r / 3;
18128            }
18129            var dStep = PI / n;
18130            var deg = -PI / 2;
18131            var xStart = x + r * cos(deg);
18132            var yStart = y + r * sin(deg);
18133            deg += dStep;
18134            var pointList = style.pointList = [];
18135            pointList.push([
18136                xStart,
18137                yStart
18138            ]);
18139            for (var i = 0, end = n * 2 - 1, ri; i < end; i++) {
18140                ri = i % 2 === 0 ? r0 : r;
18141                pointList.push([
18142                    x + ri * cos(deg),
18143                    y + ri * sin(deg)
18144                ]);
18145                deg += dStep;
18146            }
18147            pointList.push([
18148                xStart,
18149                yStart
18150            ]);
18151            ctx.moveTo(pointList[0][0], pointList[0][1]);
18152            for (var i = 0; i < pointList.length; i++) {
18153                ctx.lineTo(pointList[i][0], pointList[i][1]);
18154            }
18155            ctx.closePath();
18156            return;
18157        },
18158        getRect: function (style) {
18159            if (style.__rect) {
18160                return style.__rect;
18161            }
18162            var lineWidth;
18163            if (style.brushType == 'stroke' || style.brushType == 'fill') {
18164                lineWidth = style.lineWidth || 1;
18165            } else {
18166                lineWidth = 0;
18167            }
18168            style.__rect = {
18169                x: Math.round(style.x - style.r - lineWidth / 2),
18170                y: Math.round(style.y - style.r - lineWidth / 2),
18171                width: style.r * 2 + lineWidth,
18172                height: style.r * 2 + lineWidth
18173            };
18174            return style.__rect;
18175        }
18176    };
18177    require('../tool/util').inherits(Star, Base);
18178    return Star;
18179});define('zrender/shape/Heart', [
18180    'require',
18181    './Base',
18182    './util/PathProxy',
18183    '../tool/area',
18184    '../tool/util'
18185], function (require) {
18186    'use strict';
18187    var Base = require('./Base');
18188    var PathProxy = require('./util/PathProxy');
18189    var area = require('../tool/area');
18190    var Heart = function (options) {
18191        Base.call(this, options);
18192        this._pathProxy = new PathProxy();
18193    };
18194    Heart.prototype = {
18195        type: 'heart',
18196        buildPath: function (ctx, style) {
18197            var path = this._pathProxy || new PathProxy();
18198            path.begin(ctx);
18199            path.moveTo(style.x, style.y);
18200            path.bezierCurveTo(style.x + style.a / 2, style.y - style.b * 2 / 3, style.x + style.a * 2, style.y + style.b / 3, style.x, style.y + style.b);
18201            path.bezierCurveTo(style.x - style.a * 2, style.y + style.b / 3, style.x - style.a / 2, style.y - style.b * 2 / 3, style.x, style.y);
18202            path.closePath();
18203            return;
18204        },
18205        getRect: function (style) {
18206            if (style.__rect) {
18207                return style.__rect;
18208            }
18209            if (!this._pathProxy.isEmpty()) {
18210                this.buildPath(null, style);
18211            }
18212            return this._pathProxy.fastBoundingRect();
18213        },
18214        isCover: function (x, y) {
18215            var originPos = this.transformCoordToLocal(x, y);
18216            x = originPos[0];
18217            y = originPos[1];
18218            if (this.isCoverRect(x, y)) {
18219                return area.isInsidePath(this._pathProxy.pathCommands, this.style.lineWidth, this.style.brushType, x, y);
18220            }
18221        }
18222    };
18223    require('../tool/util').inherits(Heart, Base);
18224    return Heart;
18225});define('zrender/shape/Droplet', [
18226    'require',
18227    './Base',
18228    './util/PathProxy',
18229    '../tool/area',
18230    '../tool/util'
18231], function (require) {
18232    'use strict';
18233    var Base = require('./Base');
18234    var PathProxy = require('./util/PathProxy');
18235    var area = require('../tool/area');
18236    var Droplet = function (options) {
18237        Base.call(this, options);
18238        this._pathProxy = new PathProxy();
18239    };
18240    Droplet.prototype = {
18241        type: 'droplet',
18242        buildPath: function (ctx, style) {
18243            var path = this._pathProxy || new PathProxy();
18244            path.begin(ctx);
18245            path.moveTo(style.x, style.y + style.a);
18246            path.bezierCurveTo(style.x + style.a, style.y + style.a, style.x + style.a * 3 / 2, style.y - style.a / 3, style.x, style.y - style.b);
18247            path.bezierCurveTo(style.x - style.a * 3 / 2, style.y - style.a / 3, style.x - style.a, style.y + style.a, style.x, style.y + style.a);
18248            path.closePath();
18249        },
18250        getRect: function (style) {
18251            if (style.__rect) {
18252                return style.__rect;
18253            }
18254            if (!this._pathProxy.isEmpty()) {
18255                this.buildPath(null, style);
18256            }
18257            return this._pathProxy.fastBoundingRect();
18258        },
18259        isCover: function (x, y) {
18260            var originPos = this.transformCoordToLocal(x, y);
18261            x = originPos[0];
18262            y = originPos[1];
18263            if (this.isCoverRect(x, y)) {
18264                return area.isInsidePath(this._pathProxy.pathCommands, this.style.lineWidth, this.style.brushType, x, y);
18265            }
18266        }
18267    };
18268    require('../tool/util').inherits(Droplet, Base);
18269    return Droplet;
18270});define('zrender/tool/math', [], function () {
18271    var _radians = Math.PI / 180;
18272    function sin(angle, isDegrees) {
18273        return Math.sin(isDegrees ? angle * _radians : angle);
18274    }
18275    function cos(angle, isDegrees) {
18276        return Math.cos(isDegrees ? angle * _radians : angle);
18277    }
18278    function degreeToRadian(angle) {
18279        return angle * _radians;
18280    }
18281    function radianToDegree(angle) {
18282        return angle / _radians;
18283    }
18284    return {
18285        sin: sin,
18286        cos: cos,
18287        degreeToRadian: degreeToRadian,
18288        radianToDegree: radianToDegree
18289    };
18290});define('zrender/shape/util/PathProxy', [
18291    'require',
18292    '../../tool/vector'
18293], function (require) {
18294    var vector = require('../../tool/vector');
18295    var PathSegment = function (command, points) {
18296        this.command = command;
18297        this.points = points || null;
18298    };
18299    var PathProxy = function () {
18300        this.pathCommands = [];
18301        this._ctx = null;
18302        this._min = [];
18303        this._max = [];
18304    };
18305    PathProxy.prototype.fastBoundingRect = function () {
18306        var min = this._min;
18307        var max = this._max;
18308        min[0] = min[1] = Infinity;
18309        max[0] = max[1] = -Infinity;
18310        for (var i = 0; i < this.pathCommands.length; i++) {
18311            var seg = this.pathCommands[i];
18312            var p = seg.points;
18313            switch (seg.command) {
18314            case 'M':
18315                vector.min(min, min, p);
18316                vector.max(max, max, p);
18317                break;
18318            case 'L':
18319                vector.min(min, min, p);
18320                vector.max(max, max, p);
18321                break;
18322            case 'C':
18323                for (var j = 0; j < 6; j += 2) {
18324                    min[0] = Math.min(min[0], min[0], p[j]);
18325                    min[1] = Math.min(min[1], min[1], p[j + 1]);
18326                    max[0] = Math.max(max[0], max[0], p[j]);
18327                    max[1] = Math.max(max[1], max[1], p[j + 1]);
18328                }
18329                break;
18330            case 'Q':
18331                for (var j = 0; j < 4; j += 2) {
18332                    min[0] = Math.min(min[0], min[0], p[j]);
18333                    min[1] = Math.min(min[1], min[1], p[j + 1]);
18334                    max[0] = Math.max(max[0], max[0], p[j]);
18335                    max[1] = Math.max(max[1], max[1], p[j + 1]);
18336                }
18337                break;
18338            case 'A':
18339                var cx = p[0];
18340                var cy = p[1];
18341                var rx = p[2];
18342                var ry = p[3];
18343                min[0] = Math.min(min[0], min[0], cx - rx);
18344                min[1] = Math.min(min[1], min[1], cy - ry);
18345                max[0] = Math.max(max[0], max[0], cx + rx);
18346                max[1] = Math.max(max[1], max[1], cy + ry);
18347                break;
18348            }
18349        }
18350        return {
18351            x: min[0],
18352            y: min[1],
18353            width: max[0] - min[0],
18354            height: max[1] - min[1]
18355        };
18356    };
18357    PathProxy.prototype.begin = function (ctx) {
18358        this._ctx = ctx || null;
18359        this.pathCommands.length = 0;
18360        return this;
18361    };
18362    PathProxy.prototype.moveTo = function (x, y) {
18363        this.pathCommands.push(new PathSegment('M', [
18364            x,
18365            y
18366        ]));
18367        if (this._ctx) {
18368            this._ctx.moveTo(x, y);
18369        }
18370        return this;
18371    };
18372    PathProxy.prototype.lineTo = function (x, y) {
18373        this.pathCommands.push(new PathSegment('L', [
18374            x,
18375            y
18376        ]));
18377        if (this._ctx) {
18378            this._ctx.lineTo(x, y);
18379        }
18380        return this;
18381    };
18382    PathProxy.prototype.bezierCurveTo = function (x1, y1, x2, y2, x3, y3) {
18383        this.pathCommands.push(new PathSegment('C', [
18384            x1,
18385            y1,
18386            x2,
18387            y2,
18388            x3,
18389            y3
18390        ]));
18391        if (this._ctx) {
18392            this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
18393        }
18394        return this;
18395    };
18396    PathProxy.prototype.quadraticCurveTo = function (x1, y1, x2, y2) {
18397        this.pathCommands.push(new PathSegment('Q', [
18398            x1,
18399            y1,
18400            x2,
18401            y2
18402        ]));
18403        if (this._ctx) {
18404            this._ctx.quadraticCurveTo(x1, y1, x2, y2);
18405        }
18406        return this;
18407    };
18408    PathProxy.prototype.arc = function (cx, cy, r, startAngle, endAngle, anticlockwise) {
18409        this.pathCommands.push(new PathSegment('A', [
18410            cx,
18411            cy,
18412            r,
18413            r,
18414            startAngle,
18415            endAngle - startAngle,
18416            0,
18417            anticlockwise ? 0 : 1
18418        ]));
18419        if (this._ctx) {
18420            this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
18421        }
18422        return this;
18423    };
18424    PathProxy.prototype.arcTo = function (x1, y1, x2, y2, radius) {
18425        if (this._ctx) {
18426            this._ctx.arcTo(x1, y1, x2, y2, radius);
18427        }
18428        return this;
18429    };
18430    PathProxy.prototype.rect = function (x, y, w, h) {
18431        if (this._ctx) {
18432            this._ctx.rect(x, y, w, h);
18433        }
18434        return this;
18435    };
18436    PathProxy.prototype.closePath = function () {
18437        this.pathCommands.push(new PathSegment('z'));
18438        if (this._ctx) {
18439            this._ctx.closePath();
18440        }
18441        return this;
18442    };
18443    PathProxy.prototype.isEmpty = function () {
18444        return this.pathCommands.length === 0;
18445    };
18446    PathProxy.PathSegment = PathSegment;
18447    return PathProxy;
18448});define('zrender/shape/Line', [
18449    'require',
18450    './Base',
18451    './util/dashedLineTo',
18452    '../tool/util'
18453], function (require) {
18454    var Base = require('./Base');
18455    var dashedLineTo = require('./util/dashedLineTo');
18456    var Line = function (options) {
18457        this.brushTypeOnly = 'stroke';
18458        this.textPosition = 'end';
18459        Base.call(this, options);
18460    };
18461    Line.prototype = {
18462        type: 'line',
18463        buildPath: function (ctx, style) {
18464            if (!style.lineType || style.lineType == 'solid') {
18465                ctx.moveTo(style.xStart, style.yStart);
18466                ctx.lineTo(style.xEnd, style.yEnd);
18467            } else if (style.lineType == 'dashed' || style.lineType == 'dotted') {
18468                var dashLength = (style.lineWidth || 1) * (style.lineType == 'dashed' ? 5 : 1);
18469                dashedLineTo(ctx, style.xStart, style.yStart, style.xEnd, style.yEnd, dashLength);
18470            }
18471        },
18472        getRect: function (style) {
18473            if (style.__rect) {
18474                return style.__rect;
18475            }
18476            var lineWidth = style.lineWidth || 1;
18477            style.__rect = {
18478                x: Math.min(style.xStart, style.xEnd) - lineWidth,
18479                y: Math.min(style.yStart, style.yEnd) - lineWidth,
18480                width: Math.abs(style.xStart - style.xEnd) + lineWidth,
18481                height: Math.abs(style.yStart - style.yEnd) + lineWidth
18482            };
18483            return style.__rect;
18484        }
18485    };
18486    require('../tool/util').inherits(Line, Base);
18487    return Line;
18488});define('zrender/shape/BezierCurve', [
18489    'require',
18490    './Base',
18491    '../tool/util'
18492], function (require) {
18493    'use strict';
18494    var Base = require('./Base');
18495    var BezierCurve = function (options) {
18496        this.brushTypeOnly = 'stroke';
18497        this.textPosition = 'end';
18498        Base.call(this, options);
18499    };
18500    BezierCurve.prototype = {
18501        type: 'bezier-curve',
18502        buildPath: function (ctx, style) {
18503            ctx.moveTo(style.xStart, style.yStart);
18504            if (typeof style.cpX2 != 'undefined' && typeof style.cpY2 != 'undefined') {
18505                ctx.bezierCurveTo(style.cpX1, style.cpY1, style.cpX2, style.cpY2, style.xEnd, style.yEnd);
18506            } else {
18507                ctx.quadraticCurveTo(style.cpX1, style.cpY1, style.xEnd, style.yEnd);
18508            }
18509        },
18510        getRect: function (style) {
18511            if (style.__rect) {
18512                return style.__rect;
18513            }
18514            var _minX = Math.min(style.xStart, style.xEnd, style.cpX1);
18515            var _minY = Math.min(style.yStart, style.yEnd, style.cpY1);
18516            var _maxX = Math.max(style.xStart, style.xEnd, style.cpX1);
18517            var _maxY = Math.max(style.yStart, style.yEnd, style.cpY1);
18518            var _x2 = style.cpX2;
18519            var _y2 = style.cpY2;
18520            if (typeof _x2 != 'undefined' && typeof _y2 != 'undefined') {
18521                _minX = Math.min(_minX, _x2);
18522                _minY = Math.min(_minY, _y2);
18523                _maxX = Math.max(_maxX, _x2);
18524                _maxY = Math.max(_maxY, _y2);
18525            }
18526            var lineWidth = style.lineWidth || 1;
18527            style.__rect = {
18528                x: _minX - lineWidth,
18529                y: _minY - lineWidth,
18530                width: _maxX - _minX + lineWidth,
18531                height: _maxY - _minY + lineWidth
18532            };
18533            return style.__rect;
18534        }
18535    };
18536    require('../tool/util').inherits(BezierCurve, Base);
18537    return BezierCurve;
18538});define('zrender/shape/util/dashedLineTo', [], function () {
18539    var dashPattern = [
18540        5,
18541        5
18542    ];
18543    return function (ctx, x1, y1, x2, y2, dashLength) {
18544        if (ctx.setLineDash) {
18545            dashPattern[0] = dashPattern[1] = dashLength;
18546            ctx.setLineDash(dashPattern);
18547            ctx.moveTo(x1, y1);
18548            ctx.lineTo(x2, y2);
18549            return;
18550        }
18551        dashLength = typeof dashLength != 'number' ? 5 : dashLength;
18552        var dx = x2 - x1;
18553        var dy = y2 - y1;
18554        var numDashes = Math.floor(Math.sqrt(dx * dx + dy * dy) / dashLength);
18555        dx = dx / numDashes;
18556        dy = dy / numDashes;
18557        var flag = true;
18558        for (var i = 0; i < numDashes; ++i) {
18559            if (flag) {
18560                ctx.moveTo(x1, y1);
18561            } else {
18562                ctx.lineTo(x1, y1);
18563            }
18564            flag = !flag;
18565            x1 += dx;
18566            y1 += dy;
18567        }
18568        ctx.lineTo(x2, y2);
18569    };
18570});define('zrender/shape/Polygon', [
18571    'require',
18572    './Base',
18573    './util/smoothSpline',
18574    './util/smoothBezier',
18575    './util/dashedLineTo',
18576    '../tool/util'
18577], function (require) {
18578    var Base = require('./Base');
18579    var smoothSpline = require('./util/smoothSpline');
18580    var smoothBezier = require('./util/smoothBezier');
18581    var dashedLineTo = require('./util/dashedLineTo');
18582    var Polygon = function (options) {
18583        Base.call(this, options);
18584    };
18585    Polygon.prototype = {
18586        type: 'polygon',
18587        buildPath: function (ctx, style) {
18588            var pointList = style.pointList;
18589            if (pointList.length < 2) {
18590                return;
18591            }
18592            if (style.smooth && style.smooth !== 'spline') {
18593                var controlPoints = smoothBezier(pointList, style.smooth, true, style.smoothConstraint);
18594                ctx.moveTo(pointList[0][0], pointList[0][1]);
18595                var cp1;
18596                var cp2;
18597                var p;
18598                var len = pointList.length;
18599                for (var i = 0; i < len; i++) {
18600                    cp1 = controlPoints[i * 2];
18601                    cp2 = controlPoints[i * 2 + 1];
18602                    p = pointList[(i + 1) % len];
18603                    ctx.bezierCurveTo(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]);
18604                }
18605            } else {
18606                if (style.smooth === 'spline') {
18607                    pointList = smoothSpline(pointList, true);
18608                }
18609                if (!style.lineType || style.lineType == 'solid') {
18610                    ctx.moveTo(pointList[0][0], pointList[0][1]);
18611                    for (var i = 1, l = pointList.length; i < l; i++) {
18612                        ctx.lineTo(pointList[i][0], pointList[i][1]);
18613                    }
18614                    ctx.lineTo(pointList[0][0], pointList[0][1]);
18615                } else if (style.lineType == 'dashed' || style.lineType == 'dotted') {
18616                    var dashLength = style._dashLength || (style.lineWidth || 1) * (style.lineType == 'dashed' ? 5 : 1);
18617                    style._dashLength = dashLength;
18618                    ctx.moveTo(pointList[0][0], pointList[0][1]);
18619                    for (var i = 1, l = pointList.length; i < l; i++) {
18620                        dashedLineTo(ctx, pointList[i - 1][0], pointList[i - 1][1], pointList[i][0], pointList[i][1], dashLength);
18621                    }
18622                    dashedLineTo(ctx, pointList[pointList.length - 1][0], pointList[pointList.length - 1][1], pointList[0][0], pointList[0][1], dashLength);
18623                }
18624            }
18625            ctx.closePath();
18626            return;
18627        },
18628        getRect: function (style) {
18629            if (style.__rect) {
18630                return style.__rect;
18631            }
18632            var minX = Number.MAX_VALUE;
18633            var maxX = Number.MIN_VALUE;
18634            var minY = Number.MAX_VALUE;
18635            var maxY = Number.MIN_VALUE;
18636            var pointList = style.pointList;
18637            for (var i = 0, l = pointList.length; i < l; i++) {
18638                if (pointList[i][0] < minX) {
18639                    minX = pointList[i][0];
18640                }
18641                if (pointList[i][0] > maxX) {
18642                    maxX = pointList[i][0];
18643                }
18644                if (pointList[i][1] < minY) {
18645                    minY = pointList[i][1];
18646                }
18647                if (pointList[i][1] > maxY) {
18648                    maxY = pointList[i][1];
18649                }
18650            }
18651            var lineWidth;
18652            if (style.brushType == 'stroke' || style.brushType == 'fill') {
18653                lineWidth = style.lineWidth || 1;
18654            } else {
18655                lineWidth = 0;
18656            }
18657            style.__rect = {
18658                x: Math.round(minX - lineWidth / 2),
18659                y: Math.round(minY - lineWidth / 2),
18660                width: maxX - minX + lineWidth,
18661                height: maxY - minY + lineWidth
18662            };
18663            return style.__rect;
18664        }
18665    };
18666    require('../tool/util').inherits(Polygon, Base);
18667    return Polygon;
18668});define('echarts/util/shape/normalIsCover', [], function () {
18669    return function (x, y) {
18670        var originPos = this.transformCoordToLocal(x, y);
18671        x = originPos[0];
18672        y = originPos[1];
18673        return this.isCoverRect(x, y);
18674    };
18675});define('zrender/shape/util/smoothSpline', [
18676    'require',
18677    '../../tool/vector'
18678], function (require) {
18679    var vector = require('../../tool/vector');
18680    function interpolate(p0, p1, p2, p3, t, t2, t3) {
18681        var v0 = (p2 - p0) * 0.5;
18682        var v1 = (p3 - p1) * 0.5;
18683        return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
18684    }
18685    return function (points, isLoop, constraint) {
18686        var len = points.length;
18687        var ret = [];
18688        var distance = 0;
18689        for (var i = 1; i < len; i++) {
18690            distance += vector.distance(points[i - 1], points[i]);
18691        }
18692        var segs = distance / 5;
18693        segs = segs < len ? len : segs;
18694        for (var i = 0; i < segs; i++) {
18695            var pos = i / (segs - 1) * (isLoop ? len : len - 1);
18696            var idx = Math.floor(pos);
18697            var w = pos - idx;
18698            var p0;
18699            var p1 = points[idx % len];
18700            var p2;
18701            var p3;
18702            if (!isLoop) {
18703                p0 = points[idx === 0 ? idx : idx - 1];
18704                p2 = points[idx > len - 2 ? len - 1 : idx + 1];
18705                p3 = points[idx > len - 3 ? len - 1 : idx + 2];
18706            } else {
18707                p0 = points[(idx - 1 + len) % len];
18708                p2 = points[(idx + 1) % len];
18709                p3 = points[(idx + 2) % len];
18710            }
18711            var w2 = w * w;
18712            var w3 = w * w2;
18713            ret.push([
18714                interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
18715                interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
18716            ]);
18717        }
18718        return ret;
18719    };
18720});define('zrender/shape/util/smoothBezier', [
18721    'require',
18722    '../../tool/vector'
18723], function (require) {
18724    var vector = require('../../tool/vector');
18725    return function (points, smooth, isLoop, constraint) {
18726        var cps = [];
18727        var v = [];
18728        var v1 = [];
18729        var v2 = [];
18730        var prevPoint;
18731        var nextPoint;
18732        var hasConstraint = !!constraint;
18733        var min, max;
18734        if (hasConstraint) {
18735            min = [
18736                Infinity,
18737                Infinity
18738            ];
18739            max = [
18740                -Infinity,
18741                -Infinity
18742            ];
18743            for (var i = 0, len = points.length; i < len; i++) {
18744                vector.min(min, min, points[i]);
18745                vector.max(max, max, points[i]);
18746            }
18747            vector.min(min, min, constraint[0]);
18748            vector.max(max, max, constraint[1]);
18749        }
18750        for (var i = 0, len = points.length; i < len; i++) {
18751            var point = points[i];
18752            var prevPoint;
18753            var nextPoint;
18754            if (isLoop) {
18755                prevPoint = points[i ? i - 1 : len - 1];
18756                nextPoint = points[(i + 1) % len];
18757            } else {
18758                if (i === 0 || i === len - 1) {
18759                    cps.push(vector.clone(points[i]));
18760                    continue;
18761                } else {
18762                    prevPoint = points[i - 1];
18763                    nextPoint = points[i + 1];
18764                }
18765            }
18766            vector.sub(v, nextPoint, prevPoint);
18767            vector.scale(v, v, smooth);
18768            var d0 = vector.distance(point, prevPoint);
18769            var d1 = vector.distance(point, nextPoint);
18770            var sum = d0 + d1;
18771            if (sum !== 0) {
18772                d0 /= sum;
18773                d1 /= sum;
18774            }
18775            vector.scale(v1, v, -d0);
18776            vector.scale(v2, v, d1);
18777            var cp0 = vector.add([], point, v1);
18778            var cp1 = vector.add([], point, v2);
18779            if (hasConstraint) {
18780                vector.max(cp0, cp0, min);
18781                vector.min(cp0, cp0, max);
18782                vector.max(cp1, cp1, min);
18783                vector.min(cp1, cp1, max);
18784            }
18785            cps.push(cp0);
18786            cps.push(cp1);
18787        }
18788        if (isLoop) {
18789            cps.push(vector.clone(cps.shift()));
18790        }
18791        return cps;
18792    };
18793});define('echarts/util/ecQuery', [
18794    'require',
18795    'zrender/tool/util'
18796], function (require) {
18797    var zrUtil = require('zrender/tool/util');
18798    function query(optionTarget, optionLocation) {
18799        if (typeof optionTarget == 'undefined') {
18800            return;
18801        }
18802        if (!optionLocation) {
18803            return optionTarget;
18804        }
18805        optionLocation = optionLocation.split('.');
18806        var length = optionLocation.length;
18807        var curIdx = 0;
18808        while (curIdx < length) {
18809            optionTarget = optionTarget[optionLocation[curIdx]];
18810            if (typeof optionTarget == 'undefined') {
18811                return;
18812            }
18813            curIdx++;
18814        }
18815        return optionTarget;
18816    }
18817    function deepQuery(ctrList, optionLocation) {
18818        var finalOption;
18819        for (var i = 0, l = ctrList.length; i < l; i++) {
18820            finalOption = query(ctrList[i], optionLocation);
18821            if (typeof finalOption != 'undefined') {
18822                return finalOption;
18823            }
18824        }
18825    }
18826    function deepMerge(ctrList, optionLocation) {
18827        var finalOption;
18828        var len = ctrList.length;
18829        while (len--) {
18830            var tempOption = query(ctrList[len], optionLocation);
18831            if (typeof tempOption != 'undefined') {
18832                if (typeof finalOption == 'undefined') {
18833                    finalOption = zrUtil.clone(tempOption);
18834                } else {
18835                    zrUtil.merge(finalOption, tempOption, true);
18836                }
18837            }
18838        }
18839        return finalOption;
18840    }
18841    return {
18842        query: query,
18843        deepQuery: deepQuery,
18844        deepMerge: deepMerge
18845    };
18846});define('echarts/util/number', [], function () {
18847    function _trim(str) {
18848        return str.replace(/^\s+/, '').replace(/\s+$/, '');
18849    }
18850    function parsePercent(value, maxValue) {
18851        if (typeof value === 'string') {
18852            if (_trim(value).match(/%$/)) {
18853                return parseFloat(value) / 100 * maxValue;
18854            }
18855            return parseFloat(value);
18856        }
18857        return value;
18858    }
18859    function parseCenter(zr, center) {
18860        return [
18861            parsePercent(center[0], zr.getWidth()),
18862            parsePercent(center[1], zr.getHeight())
18863        ];
18864    }
18865    function parseRadius(zr, radius) {
18866        if (!(radius instanceof Array)) {
18867            radius = [
18868                0,
18869                radius
18870            ];
18871        }
18872        var zrSize = Math.min(zr.getWidth(), zr.getHeight()) / 2;
18873        return [
18874            parsePercent(radius[0], zrSize),
18875            parsePercent(radius[1], zrSize)
18876        ];
18877    }
18878    function addCommas(x) {
18879        if (isNaN(x)) {
18880            return '-';
18881        }
18882        x = (x + '').split('.');
18883        return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,') + (x.length > 1 ? '.' + x[1] : '');
18884    }
18885    function getPrecision(val) {
18886        var e = 1;
18887        var count = 0;
18888        while (Math.round(val * e) / e !== val) {
18889            e *= 10;
18890            count++;
18891        }
18892        return count;
18893    }
18894    return {
18895        parsePercent: parsePercent,
18896        parseCenter: parseCenter,
18897        parseRadius: parseRadius,
18898        addCommas: addCommas,
18899        getPrecision: getPrecision
18900    };
18901});define('echarts/data/KDTree', [
18902    'require',
18903    './quickSelect'
18904], function (require) {
18905    var quickSelect = require('./quickSelect');
18906    function Node(axis, data) {
18907        this.left = null;
18908        this.right = null;
18909        this.axis = axis;
18910        this.data = data;
18911    }
18912    var KDTree = function (points, dimension) {
18913        if (!points.length) {
18914            return;
18915        }
18916        if (!dimension) {
18917            dimension = points[0].array.length;
18918        }
18919        this.dimension = dimension;
18920        this.root = this._buildTree(points, 0, points.length - 1, 0);
18921        this._stack = [];
18922        this._nearstNList = [];
18923    };
18924    KDTree.prototype._buildTree = function (points, left, right, axis) {
18925        if (right < left) {
18926            return null;
18927        }
18928        var medianIndex = Math.floor((left + right) / 2);
18929        medianIndex = quickSelect(points, left, right, medianIndex, function (a, b) {
18930            return a.array[axis] - b.array[axis];
18931        });
18932        var median = points[medianIndex];
18933        var node = new Node(axis, median);
18934        axis = (axis + 1) % this.dimension;
18935        if (right > left) {
18936            node.left = this._buildTree(points, left, medianIndex - 1, axis);
18937            node.right = this._buildTree(points, medianIndex + 1, right, axis);
18938        }
18939        return node;
18940    };
18941    KDTree.prototype.nearest = function (target, squaredDistance) {
18942        var curr = this.root;
18943        var stack = this._stack;
18944        var idx = 0;
18945        var minDist = Infinity;
18946        var nearestNode = null;
18947        if (curr.data !== target) {
18948            minDist = squaredDistance(curr.data, target);
18949            nearestNode = curr;
18950        }
18951        if (target.array[curr.axis] < curr.data.array[curr.axis]) {
18952            curr.right && (stack[idx++] = curr.right);
18953            curr.left && (stack[idx++] = curr.left);
18954        } else {
18955            curr.left && (stack[idx++] = curr.left);
18956            curr.right && (stack[idx++] = curr.right);
18957        }
18958        while (idx--) {
18959            curr = stack[idx];
18960            var currDist = target.array[curr.axis] - curr.data.array[curr.axis];
18961            var isLeft = currDist < 0;
18962            var needsCheckOtherSide = false;
18963            currDist = currDist * currDist;
18964            if (currDist < minDist) {
18965                currDist = squaredDistance(curr.data, target);
18966                if (currDist < minDist && curr.data !== target) {
18967                    minDist = currDist;
18968                    nearestNode = curr;
18969                }
18970                needsCheckOtherSide = true;
18971            }
18972            if (isLeft) {
18973                if (needsCheckOtherSide) {
18974                    curr.right && (stack[idx++] = curr.right);
18975                }
18976                curr.left && (stack[idx++] = curr.left);
18977            } else {
18978                if (needsCheckOtherSide) {
18979                    curr.left && (stack[idx++] = curr.left);
18980                }
18981                curr.right && (stack[idx++] = curr.right);
18982            }
18983        }
18984        return nearestNode.data;
18985    };
18986    KDTree.prototype._addNearest = function (found, dist, node) {
18987        var nearestNList = this._nearstNList;
18988        for (var i = found - 1; i > 0; i--) {
18989            if (dist >= nearestNList[i - 1].dist) {
18990                break;
18991            } else {
18992                nearestNList[i].dist = nearestNList[i - 1].dist;
18993                nearestNList[i].node = nearestNList[i - 1].node;
18994            }
18995        }
18996        nearestNList[i].dist = dist;
18997        nearestNList[i].node = node;
18998    };
18999    KDTree.prototype.nearestN = function (target, N, squaredDistance, output) {
19000        if (N <= 0) {
19001            output.length = 0;
19002            return output;
19003        }
19004        var curr = this.root;
19005        var stack = this._stack;
19006        var idx = 0;
19007        var nearestNList = this._nearstNList;
19008        for (var i = 0; i < N; i++) {
19009            if (!nearestNList[i]) {
19010                nearestNList[i] = {};
19011            }
19012            nearestNList[i].dist = 0;
19013            nearestNList[i].node = null;
19014        }
19015        var currDist = squaredDistance(curr.data, target);
19016        var found = 0;
19017        if (curr.data !== target) {
19018            found++;
19019            this._addNearest(found, currDist, curr);
19020        }
19021        if (target.array[curr.axis] < curr.data.array[curr.axis]) {
19022            curr.right && (stack[idx++] = curr.right);
19023            curr.left && (stack[idx++] = curr.left);
19024        } else {
19025            curr.left && (stack[idx++] = curr.left);
19026            curr.right && (stack[idx++] = curr.right);
19027        }
19028        while (idx--) {
19029            curr = stack[idx];
19030            var currDist = target.array[curr.axis] - curr.data.array[curr.axis];
19031            var isLeft = currDist < 0;
19032            var needsCheckOtherSide = false;
19033            currDist = currDist * currDist;
19034            if (found < N || currDist < nearestNList[found - 1].dist) {
19035                currDist = squaredDistance(curr.data, target);
19036                if ((found < N || currDist < nearestNList[found - 1].dist) && curr.data !== target) {
19037                    if (found < N) {
19038                        found++;
19039                    }
19040                    this._addNearest(found, currDist, curr);
19041                }
19042                needsCheckOtherSide = true;
19043            }
19044            if (isLeft) {
19045                if (needsCheckOtherSide) {
19046                    curr.right && (stack[idx++] = curr.right);
19047                }
19048                curr.left && (stack[idx++] = curr.left);
19049            } else {
19050                if (needsCheckOtherSide) {
19051                    curr.left && (stack[idx++] = curr.left);
19052                }
19053                curr.right && (stack[idx++] = curr.right);
19054            }
19055        }
19056        for (var i = 0; i < found; i++) {
19057            output[i] = nearestNList[i].node.data;
19058        }
19059        output.length = found;
19060        return output;
19061    };
19062    return KDTree;
19063});define('echarts/data/quickSelect', ['require'], function (require) {
19064    function defaultCompareFunc(a, b) {
19065        return a - b;
19066    }
19067    function swapElement(list, idx0, idx1) {
19068        var tmp = list[idx0];
19069        list[idx0] = list[idx1];
19070        list[idx1] = tmp;
19071    }
19072    function select(list, left, right, nth, compareFunc) {
19073        var pivotIdx = left;
19074        while (right > left) {
19075            var pivotIdx = Math.round((right + left) / 2);
19076            var pivotValue = list[pivotIdx];
19077            swapElement(list, pivotIdx, right);
19078            pivotIdx = left;
19079            for (var i = left; i <= right - 1; i++) {
19080                if (compareFunc(pivotValue, list[i]) >= 0) {
19081                    swapElement(list, i, pivotIdx);
19082                    pivotIdx++;
19083                }
19084            }
19085            swapElement(list, right, pivotIdx);
19086            if (pivotIdx === nth) {
19087                return pivotIdx;
19088            } else if (pivotIdx < nth) {
19089                left = pivotIdx + 1;
19090            } else {
19091                right = pivotIdx - 1;
19092            }
19093        }
19094        return left;
19095    }
19096    function quickSelect(list, left, right, nth, compareFunc) {
19097        if (arguments.length <= 3) {
19098            nth = left;
19099            if (arguments.length == 2) {
19100                compareFunc = defaultCompareFunc;
19101            } else {
19102                compareFunc = right;
19103            }
19104            left = 0;
19105            right = list.length - 1;
19106        }
19107        return select(list, left, right, nth, compareFunc);
19108    }
19109    return quickSelect;
19110});define('echarts/component/dataView', [
19111    'require',
19112    './base',
19113    '../config',
19114    'zrender/tool/util',
19115    '../component'
19116], function (require) {
19117    var Base = require('./base');
19118    var ecConfig = require('../config');
19119    var zrUtil = require('zrender/tool/util');
19120    function DataView(ecTheme, messageCenter, zr, option, myChart) {
19121        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
19122        this.dom = myChart.dom;
19123        this._tDom = document.createElement('div');
19124        this._textArea = document.createElement('textArea');
19125        this._buttonRefresh = document.createElement('button');
19126        this._buttonRefresh.setAttribute('type', 'button');
19127        this._buttonClose = document.createElement('button');
19128        this._buttonClose.setAttribute('type', 'button');
19129        this._hasShow = false;
19130        this._zrHeight = zr.getHeight();
19131        this._zrWidth = zr.getWidth();
19132        this._tDom.className = 'echarts-dataview';
19133        this.hide();
19134        this.dom.firstChild.appendChild(this._tDom);
19135        if (window.addEventListener) {
19136            this._tDom.addEventListener('click', this._stop);
19137            this._tDom.addEventListener('mousewheel', this._stop);
19138            this._tDom.addEventListener('mousemove', this._stop);
19139            this._tDom.addEventListener('mousedown', this._stop);
19140            this._tDom.addEventListener('mouseup', this._stop);
19141            this._tDom.addEventListener('touchstart', this._stop);
19142            this._tDom.addEventListener('touchmove', this._stop);
19143            this._tDom.addEventListener('touchend', this._stop);
19144        } else {
19145            this._tDom.attachEvent('onclick', this._stop);
19146            this._tDom.attachEvent('onmousewheel', this._stop);
19147            this._tDom.attachEvent('onmousemove', this._stop);
19148            this._tDom.attachEvent('onmousedown', this._stop);
19149            this._tDom.attachEvent('onmouseup', this._stop);
19150        }
19151    }
19152    DataView.prototype = {
19153        type: ecConfig.COMPONENT_TYPE_DATAVIEW,
19154        _lang: [
19155            'Data View',
19156            'close',
19157            'refresh'
19158        ],
19159        _gCssText: 'position:absolute;' + 'display:block;' + 'overflow:hidden;' + 'transition:height 0.8s,background-color 1s;' + '-moz-transition:height 0.8s,background-color 1s;' + '-webkit-transition:height 0.8s,background-color 1s;' + '-o-transition:height 0.8s,background-color 1s;' + 'z-index:1;' + 'left:0;' + 'top:0;',
19160        hide: function () {
19161            this._sizeCssText = 'width:' + this._zrWidth + 'px;' + 'height:' + 0 + 'px;' + 'background-color:#f0ffff;';
19162            this._tDom.style.cssText = this._gCssText + this._sizeCssText;
19163        },
19164        show: function (newOption) {
19165            this._hasShow = true;
19166            var lang = this.query(this.option, 'toolbox.feature.dataView.lang') || this._lang;
19167            this.option = newOption;
19168            this._tDom.innerHTML = '<p style="padding:8px 0;margin:0 0 10px 0;' + 'border-bottom:1px solid #eee">' + (lang[0] || this._lang[0]) + '</p>';
19169            var customContent = this.query(this.option, 'toolbox.feature.dataView.optionToContent');
19170            if (typeof customContent != 'function') {
19171                this._textArea.value = this._optionToContent();
19172            } else {
19173                this._textArea = document.createElement('div');
19174                this._textArea.innerHTML = customContent(this.option);
19175            }
19176            this._textArea.style.cssText = 'display:block;margin:0 0 8px 0;padding:4px 6px;overflow:auto;' + 'width:100%;' + 'height:' + (this._zrHeight - 100) + 'px;';
19177            this._tDom.appendChild(this._textArea);
19178            this._buttonClose.style.cssText = 'float:right;padding:1px 6px;';
19179            this._buttonClose.innerHTML = lang[1] || this._lang[1];
19180            var self = this;
19181            this._buttonClose.onclick = function () {
19182                self.hide();
19183            };
19184            this._tDom.appendChild(this._buttonClose);
19185            if (this.query(this.option, 'toolbox.feature.dataView.readOnly') === false) {
19186                this._buttonRefresh.style.cssText = 'float:right;margin-right:10px;padding:1px 6px;';
19187                this._buttonRefresh.innerHTML = lang[2] || this._lang[2];
19188                this._buttonRefresh.onclick = function () {
19189                    self._save();
19190                };
19191                this._textArea.readOnly = false;
19192                this._textArea.style.cursor = 'default';
19193            } else {
19194                this._buttonRefresh.style.cssText = 'display:none';
19195                this._textArea.readOnly = true;
19196                this._textArea.style.cursor = 'text';
19197            }
19198            this._tDom.appendChild(this._buttonRefresh);
19199            this._sizeCssText = 'width:' + this._zrWidth + 'px;' + 'height:' + this._zrHeight + 'px;' + 'background-color:#fff;';
19200            this._tDom.style.cssText = this._gCssText + this._sizeCssText;
19201        },
19202        _optionToContent: function () {
19203            var i;
19204            var j;
19205            var k;
19206            var len;
19207            var data;
19208            var valueList;
19209            var axisList = [];
19210            var content = '';
19211            if (this.option.xAxis) {
19212                if (this.option.xAxis instanceof Array) {
19213                    axisList = this.option.xAxis;
19214                } else {
19215                    axisList = [this.option.xAxis];
19216                }
19217                for (i = 0, len = axisList.length; i < len; i++) {
19218                    if ((axisList[i].type || 'category') == 'category') {
19219                        valueList = [];
19220                        for (j = 0, k = axisList[i].data.length; j < k; j++) {
19221                            valueList.push(this.getDataFromOption(axisList[i].data[j]));
19222                        }
19223                        content += valueList.join(', ') + '\n\n';
19224                    }
19225                }
19226            }
19227            if (this.option.yAxis) {
19228                if (this.option.yAxis instanceof Array) {
19229                    axisList = this.option.yAxis;
19230                } else {
19231                    axisList = [this.option.yAxis];
19232                }
19233                for (i = 0, len = axisList.length; i < len; i++) {
19234                    if (axisList[i].type == 'category') {
19235                        valueList = [];
19236                        for (j = 0, k = axisList[i].data.length; j < k; j++) {
19237                            valueList.push(this.getDataFromOption(axisList[i].data[j]));
19238                        }
19239                        content += valueList.join(', ') + '\n\n';
19240                    }
19241                }
19242            }
19243            var series = this.option.series;
19244            var itemName;
19245            for (i = 0, len = series.length; i < len; i++) {
19246                valueList = [];
19247                for (j = 0, k = series[i].data.length; j < k; j++) {
19248                    data = series[i].data[j];
19249                    if (series[i].type == ecConfig.CHART_TYPE_PIE || series[i].type == ecConfig.CHART_TYPE_MAP) {
19250                        itemName = (data.name || '-') + ':';
19251                    } else {
19252                        itemName = '';
19253                    }
19254                    if (series[i].type == ecConfig.CHART_TYPE_SCATTER) {
19255                        data = this.getDataFromOption(data).join(', ');
19256                    }
19257                    valueList.push(itemName + this.getDataFromOption(data));
19258                }
19259                content += (series[i].name || '-') + ' : \n';
19260                content += valueList.join(series[i].type == ecConfig.CHART_TYPE_SCATTER ? '\n' : ', ');
19261                content += '\n\n';
19262            }
19263            return content;
19264        },
19265        _save: function () {
19266            var customContent = this.query(this.option, 'toolbox.feature.dataView.contentToOption');
19267            if (typeof customContent != 'function') {
19268                var text = this._textArea.value.split('\n');
19269                var content = [];
19270                for (var i = 0, l = text.length; i < l; i++) {
19271                    text[i] = this._trim(text[i]);
19272                    if (text[i] !== '') {
19273                        content.push(text[i]);
19274                    }
19275                }
19276                this._contentToOption(content);
19277            } else {
19278                customContent(this._textArea, this.option);
19279            }
19280            this.hide();
19281            var self = this;
19282            setTimeout(function () {
19283                self.messageCenter && self.messageCenter.dispatch(ecConfig.EVENT.DATA_VIEW_CHANGED, null, { option: self.option }, self.myChart);
19284            }, self.canvasSupported ? 800 : 100);
19285        },
19286        _contentToOption: function (content) {
19287            var i;
19288            var j;
19289            var k;
19290            var len;
19291            var data;
19292            var axisList = [];
19293            var contentIdx = 0;
19294            var contentValueList;
19295            var value;
19296            if (this.option.xAxis) {
19297                if (this.option.xAxis instanceof Array) {
19298                    axisList = this.option.xAxis;
19299                } else {
19300                    axisList = [this.option.xAxis];
19301                }
19302                for (i = 0, len = axisList.length; i < len; i++) {
19303                    if ((axisList[i].type || 'category') == 'category') {
19304                        contentValueList = content[contentIdx].split(',');
19305                        for (j = 0, k = axisList[i].data.length; j < k; j++) {
19306                            value = this._trim(contentValueList[j] || '');
19307                            data = axisList[i].data[j];
19308                            if (typeof axisList[i].data[j].value != 'undefined') {
19309                                axisList[i].data[j].value = value;
19310                            } else {
19311                                axisList[i].data[j] = value;
19312                            }
19313                        }
19314                        contentIdx++;
19315                    }
19316                }
19317            }
19318            if (this.option.yAxis) {
19319                if (this.option.yAxis instanceof Array) {
19320                    axisList = this.option.yAxis;
19321                } else {
19322                    axisList = [this.option.yAxis];
19323                }
19324                for (i = 0, len = axisList.length; i < len; i++) {
19325                    if (axisList[i].type == 'category') {
19326                        contentValueList = content[contentIdx].split(',');
19327                        for (j = 0, k = axisList[i].data.length; j < k; j++) {
19328                            value = this._trim(contentValueList[j] || '');
19329                            data = axisList[i].data[j];
19330                            if (typeof axisList[i].data[j].value != 'undefined') {
19331                                axisList[i].data[j].value = value;
19332                            } else {
19333                                axisList[i].data[j] = value;
19334                            }
19335                        }
19336                        contentIdx++;
19337                    }
19338                }
19339            }
19340            var series = this.option.series;
19341            for (i = 0, len = series.length; i < len; i++) {
19342                contentIdx++;
19343                if (series[i].type == ecConfig.CHART_TYPE_SCATTER) {
19344                    for (var j = 0, k = series[i].data.length; j < k; j++) {
19345                        contentValueList = content[contentIdx];
19346                        value = contentValueList.replace(' ', '').split(',');
19347                        if (typeof series[i].data[j].value != 'undefined') {
19348                            series[i].data[j].value = value;
19349                        } else {
19350                            series[i].data[j] = value;
19351                        }
19352                        contentIdx++;
19353                    }
19354                } else {
19355                    contentValueList = content[contentIdx].split(',');
19356                    for (var j = 0, k = series[i].data.length; j < k; j++) {
19357                        value = (contentValueList[j] || '').replace(/.*:/, '');
19358                        value = this._trim(value);
19359                        value = value != '-' && value !== '' ? value - 0 : '-';
19360                        if (typeof series[i].data[j].value != 'undefined') {
19361                            series[i].data[j].value = value;
19362                        } else {
19363                            series[i].data[j] = value;
19364                        }
19365                    }
19366                    contentIdx++;
19367                }
19368            }
19369        },
19370        _trim: function (str) {
19371            var trimer = new RegExp('(^[\\s\\t\\xa0\\u3000]+)|([\\u3000\\xa0\\s\\t]+$)', 'g');
19372            return str.replace(trimer, '');
19373        },
19374        _stop: function (e) {
19375            e = e || window.event;
19376            if (e.stopPropagation) {
19377                e.stopPropagation();
19378            } else {
19379                e.cancelBubble = true;
19380            }
19381        },
19382        resize: function () {
19383            this._zrHeight = this.zr.getHeight();
19384            this._zrWidth = this.zr.getWidth();
19385            if (this._tDom.offsetHeight > 10) {
19386                this._sizeCssText = 'width:' + this._zrWidth + 'px;' + 'height:' + this._zrHeight + 'px;' + 'background-color:#fff;';
19387                this._tDom.style.cssText = this._gCssText + this._sizeCssText;
19388                this._textArea.style.cssText = 'display:block;margin:0 0 8px 0;' + 'padding:4px 6px;overflow:auto;' + 'width:100%;' + 'height:' + (this._zrHeight - 100) + 'px;';
19389            }
19390        },
19391        dispose: function () {
19392            if (window.removeEventListener) {
19393                this._tDom.removeEventListener('click', this._stop);
19394                this._tDom.removeEventListener('mousewheel', this._stop);
19395                this._tDom.removeEventListener('mousemove', this._stop);
19396                this._tDom.removeEventListener('mousedown', this._stop);
19397                this._tDom.removeEventListener('mouseup', this._stop);
19398                this._tDom.removeEventListener('touchstart', this._stop);
19399                this._tDom.removeEventListener('touchmove', this._stop);
19400                this._tDom.removeEventListener('touchend', this._stop);
19401            } else {
19402                this._tDom.detachEvent('onclick', this._stop);
19403                this._tDom.detachEvent('onmousewheel', this._stop);
19404                this._tDom.detachEvent('onmousemove', this._stop);
19405                this._tDom.detachEvent('onmousedown', this._stop);
19406                this._tDom.detachEvent('onmouseup', this._stop);
19407            }
19408            this._buttonRefresh.onclick = null;
19409            this._buttonClose.onclick = null;
19410            if (this._hasShow) {
19411                this._tDom.removeChild(this._textArea);
19412                this._tDom.removeChild(this._buttonRefresh);
19413                this._tDom.removeChild(this._buttonClose);
19414            }
19415            this._textArea = null;
19416            this._buttonRefresh = null;
19417            this._buttonClose = null;
19418            this.dom.firstChild.removeChild(this._tDom);
19419            this._tDom = null;
19420        }
19421    };
19422    zrUtil.inherits(DataView, Base);
19423    require('../component').define('dataView', DataView);
19424    return DataView;
19425});define('echarts/util/shape/Cross', [
19426    'require',
19427    'zrender/shape/Base',
19428    'zrender/shape/Line',
19429    'zrender/tool/util',
19430    './normalIsCover'
19431], function (require) {
19432    var Base = require('zrender/shape/Base');
19433    var LineShape = require('zrender/shape/Line');
19434    var zrUtil = require('zrender/tool/util');
19435    function Cross(options) {
19436        Base.call(this, options);
19437    }
19438    Cross.prototype = {
19439        type: 'cross',
19440        buildPath: function (ctx, style) {
19441            var rect = style.rect;
19442            style.xStart = rect.x;
19443            style.xEnd = rect.x + rect.width;
19444            style.yStart = style.yEnd = style.y;
19445            LineShape.prototype.buildPath(ctx, style);
19446            style.xStart = style.xEnd = style.x;
19447            style.yStart = rect.y;
19448            style.yEnd = rect.y + rect.height;
19449            LineShape.prototype.buildPath(ctx, style);
19450        },
19451        getRect: function (style) {
19452            return style.rect;
19453        },
19454        isCover: require('./normalIsCover')
19455    };
19456    zrUtil.inherits(Cross, Base);
19457    return Cross;
19458});define('zrender/shape/Sector', [
19459    'require',
19460    '../tool/math',
19461    '../tool/computeBoundingBox',
19462    '../tool/vector',
19463    './Base',
19464    '../tool/util'
19465], function (require) {
19466    var math = require('../tool/math');
19467    var computeBoundingBox = require('../tool/computeBoundingBox');
19468    var vec2 = require('../tool/vector');
19469    var Base = require('./Base');
19470    var min0 = vec2.create();
19471    var min1 = vec2.create();
19472    var max0 = vec2.create();
19473    var max1 = vec2.create();
19474    var Sector = function (options) {
19475        Base.call(this, options);
19476    };
19477    Sector.prototype = {
19478        type: 'sector',
19479        buildPath: function (ctx, style) {
19480            var x = style.x;
19481            var y = style.y;
19482            var r0 = style.r0 || 0;
19483            var r = style.r;
19484            var startAngle = style.startAngle;
19485            var endAngle = style.endAngle;
19486            var clockWise = style.clockWise || false;
19487            startAngle = math.degreeToRadian(startAngle);
19488            endAngle = math.degreeToRadian(endAngle);
19489            if (!clockWise) {
19490                startAngle = -startAngle;
19491                endAngle = -endAngle;
19492            }
19493            var unitX = math.cos(startAngle);
19494            var unitY = math.sin(startAngle);
19495            ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
19496            ctx.lineTo(unitX * r + x, unitY * r + y);
19497            ctx.arc(x, y, r, startAngle, endAngle, !clockWise);
19498            ctx.lineTo(math.cos(endAngle) * r0 + x, math.sin(endAngle) * r0 + y);
19499            if (r0 !== 0) {
19500                ctx.arc(x, y, r0, endAngle, startAngle, clockWise);
19501            }
19502            ctx.closePath();
19503            return;
19504        },
19505        getRect: function (style) {
19506            if (style.__rect) {
19507                return style.__rect;
19508            }
19509            var x = style.x;
19510            var y = style.y;
19511            var r0 = style.r0 || 0;
19512            var r = style.r;
19513            var startAngle = math.degreeToRadian(style.startAngle);
19514            var endAngle = math.degreeToRadian(style.endAngle);
19515            var clockWise = style.clockWise;
19516            if (!clockWise) {
19517                startAngle = -startAngle;
19518                endAngle = -endAngle;
19519            }
19520            if (r0 > 1) {
19521                computeBoundingBox.arc(x, y, r0, startAngle, endAngle, !clockWise, min0, max0);
19522            } else {
19523                min0[0] = max0[0] = x;
19524                min0[1] = max0[1] = y;
19525            }
19526            computeBoundingBox.arc(x, y, r, startAngle, endAngle, !clockWise, min1, max1);
19527            vec2.min(min0, min0, min1);
19528            vec2.max(max0, max0, max1);
19529            style.__rect = {
19530                x: min0[0],
19531                y: min0[1],
19532                width: max0[0] - min0[0],
19533                height: max0[1] - min0[1]
19534            };
19535            return style.__rect;
19536        }
19537    };
19538    require('../tool/util').inherits(Sector, Base);
19539    return Sector;
19540});define('echarts/util/shape/Candle', [
19541    'require',
19542    'zrender/shape/Base',
19543    'zrender/tool/util',
19544    './normalIsCover'
19545], function (require) {
19546    var Base = require('zrender/shape/Base');
19547    var zrUtil = require('zrender/tool/util');
19548    function Candle(options) {
19549        Base.call(this, options);
19550    }
19551    Candle.prototype = {
19552        type: 'candle',
19553        _numberOrder: function (a, b) {
19554            return b - a;
19555        },
19556        buildPath: function (ctx, style) {
19557            var yList = zrUtil.clone(style.y).sort(this._numberOrder);
19558            ctx.moveTo(style.x, yList[3]);
19559            ctx.lineTo(style.x, yList[2]);
19560            ctx.moveTo(style.x - style.width / 2, yList[2]);
19561            ctx.rect(style.x - style.width / 2, yList[2], style.width, yList[1] - yList[2]);
19562            ctx.moveTo(style.x, yList[1]);
19563            ctx.lineTo(style.x, yList[0]);
19564        },
19565        getRect: function (style) {
19566            if (!style.__rect) {
19567                var lineWidth = 0;
19568                if (style.brushType == 'stroke' || style.brushType == 'fill') {
19569                    lineWidth = style.lineWidth || 1;
19570                }
19571                var yList = zrUtil.clone(style.y).sort(this._numberOrder);
19572                style.__rect = {
19573                    x: Math.round(style.x - style.width / 2 - lineWidth / 2),
19574                    y: Math.round(yList[3] - lineWidth / 2),
19575                    width: style.width + lineWidth,
19576                    height: yList[0] - yList[3] + lineWidth
19577                };
19578            }
19579            return style.__rect;
19580        },
19581        isCover: require('./normalIsCover')
19582    };
19583    zrUtil.inherits(Candle, Base);
19584    return Candle;
19585});define('zrender/tool/computeBoundingBox', [
19586    'require',
19587    './vector',
19588    './curve'
19589], function (require) {
19590    var vec2 = require('./vector');
19591    var curve = require('./curve');
19592    function computeBoundingBox(points, min, max) {
19593        if (points.length === 0) {
19594            return;
19595        }
19596        var left = points[0][0];
19597        var right = points[0][0];
19598        var top = points[0][1];
19599        var bottom = points[0][1];
19600        for (var i = 1; i < points.length; i++) {
19601            var p = points[i];
19602            if (p[0] < left) {
19603                left = p[0];
19604            }
19605            if (p[0] > right) {
19606                right = p[0];
19607            }
19608            if (p[1] < top) {
19609                top = p[1];
19610            }
19611            if (p[1] > bottom) {
19612                bottom = p[1];
19613            }
19614        }
19615        min[0] = left;
19616        min[1] = top;
19617        max[0] = right;
19618        max[1] = bottom;
19619    }
19620    function computeCubeBezierBoundingBox(p0, p1, p2, p3, min, max) {
19621        var xDim = [];
19622        curve.cubicExtrema(p0[0], p1[0], p2[0], p3[0], xDim);
19623        for (var i = 0; i < xDim.length; i++) {
19624            xDim[i] = curve.cubicAt(p0[0], p1[0], p2[0], p3[0], xDim[i]);
19625        }
19626        var yDim = [];
19627        curve.cubicExtrema(p0[1], p1[1], p2[1], p3[1], yDim);
19628        for (var i = 0; i < yDim.length; i++) {
19629            yDim[i] = curve.cubicAt(p0[1], p1[1], p2[1], p3[1], yDim[i]);
19630        }
19631        xDim.push(p0[0], p3[0]);
19632        yDim.push(p0[1], p3[1]);
19633        var left = Math.min.apply(null, xDim);
19634        var right = Math.max.apply(null, xDim);
19635        var top = Math.min.apply(null, yDim);
19636        var bottom = Math.max.apply(null, yDim);
19637        min[0] = left;
19638        min[1] = top;
19639        max[0] = right;
19640        max[1] = bottom;
19641    }
19642    function computeQuadraticBezierBoundingBox(p0, p1, p2, min, max) {
19643        var t1 = curve.quadraticExtremum(p0[0], p1[0], p2[0]);
19644        var t2 = curve.quadraticExtremum(p0[1], p1[1], p2[1]);
19645        t1 = Math.max(Math.min(t1, 1), 0);
19646        t2 = Math.max(Math.min(t2, 1), 0);
19647        var ct1 = 1 - t1;
19648        var ct2 = 1 - t2;
19649        var x1 = ct1 * ct1 * p0[0] + 2 * ct1 * t1 * p1[0] + t1 * t1 * p2[0];
19650        var y1 = ct1 * ct1 * p0[1] + 2 * ct1 * t1 * p1[1] + t1 * t1 * p2[1];
19651        var x2 = ct2 * ct2 * p0[0] + 2 * ct2 * t2 * p1[0] + t2 * t2 * p2[0];
19652        var y2 = ct2 * ct2 * p0[1] + 2 * ct2 * t2 * p1[1] + t2 * t2 * p2[1];
19653        min[0] = Math.min(p0[0], p2[0], x1, x2);
19654        min[1] = Math.min(p0[1], p2[1], y1, y2);
19655        max[0] = Math.max(p0[0], p2[0], x1, x2);
19656        max[1] = Math.max(p0[1], p2[1], y1, y2);
19657    }
19658    var start = vec2.create();
19659    var end = vec2.create();
19660    var extremity = vec2.create();
19661    var computeArcBoundingBox = function (x, y, r, startAngle, endAngle, anticlockwise, min, max) {
19662        if (Math.abs(startAngle - endAngle) >= Math.PI * 2) {
19663            min[0] = x - r;
19664            min[1] = y - r;
19665            max[0] = x + r;
19666            max[1] = y + r;
19667            return;
19668        }
19669        start[0] = Math.cos(startAngle) * r + x;
19670        start[1] = Math.sin(startAngle) * r + y;
19671        end[0] = Math.cos(endAngle) * r + x;
19672        end[1] = Math.sin(endAngle) * r + y;
19673        vec2.min(min, start, end);
19674        vec2.max(max, start, end);
19675        startAngle = startAngle % (Math.PI * 2);
19676        if (startAngle < 0) {
19677            startAngle = startAngle + Math.PI * 2;
19678        }
19679        endAngle = endAngle % (Math.PI * 2);
19680        if (endAngle < 0) {
19681            endAngle = endAngle + Math.PI * 2;
19682        }
19683        if (startAngle > endAngle && !anticlockwise) {
19684            endAngle += Math.PI * 2;
19685        } else if (startAngle < endAngle && anticlockwise) {
19686            startAngle += Math.PI * 2;
19687        }
19688        if (anticlockwise) {
19689            var tmp = endAngle;
19690            endAngle = startAngle;
19691            startAngle = tmp;
19692        }
19693        for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
19694            if (angle > startAngle) {
19695                extremity[0] = Math.cos(angle) * r + x;
19696                extremity[1] = Math.sin(angle) * r + y;
19697                vec2.min(min, extremity, min);
19698                vec2.max(max, extremity, max);
19699            }
19700        }
19701    };
19702    computeBoundingBox.cubeBezier = computeCubeBezierBoundingBox;
19703    computeBoundingBox.quadraticBezier = computeQuadraticBezierBoundingBox;
19704    computeBoundingBox.arc = computeArcBoundingBox;
19705    return computeBoundingBox;
19706});define('echarts/util/shape/Chain', [
19707    'require',
19708    'zrender/shape/Base',
19709    './Icon',
19710    'zrender/shape/util/dashedLineTo',
19711    'zrender/tool/util',
19712    'zrender/tool/matrix'
19713], function (require) {
19714    var Base = require('zrender/shape/Base');
19715    var IconShape = require('./Icon');
19716    var dashedLineTo = require('zrender/shape/util/dashedLineTo');
19717    var zrUtil = require('zrender/tool/util');
19718    var matrix = require('zrender/tool/matrix');
19719    function Chain(options) {
19720        Base.call(this, options);
19721    }
19722    Chain.prototype = {
19723        type: 'chain',
19724        brush: function (ctx, isHighlight) {
19725            var style = this.style;
19726            if (isHighlight) {
19727                style = this.getHighlightStyle(style, this.highlightStyle || {});
19728            }
19729            ctx.save();
19730            this.setContext(ctx, style);
19731            this.setTransform(ctx);
19732            ctx.save();
19733            ctx.beginPath();
19734            this.buildLinePath(ctx, style);
19735            ctx.stroke();
19736            ctx.restore();
19737            this.brushSymbol(ctx, style);
19738            ctx.restore();
19739            return;
19740        },
19741        buildLinePath: function (ctx, style) {
19742            var x = style.x;
19743            var y = style.y + 5;
19744            var width = style.width;
19745            var height = style.height / 2 - 10;
19746            ctx.moveTo(x, y);
19747            ctx.lineTo(x, y + height);
19748            ctx.moveTo(x + width, y);
19749            ctx.lineTo(x + width, y + height);
19750            ctx.moveTo(x, y + height / 2);
19751            if (!style.lineType || style.lineType == 'solid') {
19752                ctx.lineTo(x + width, y + height / 2);
19753            } else if (style.lineType == 'dashed' || style.lineType == 'dotted') {
19754                var dashLength = (style.lineWidth || 1) * (style.lineType == 'dashed' ? 5 : 1);
19755                dashedLineTo(ctx, x, y + height / 2, x + width, y + height / 2, dashLength);
19756            }
19757        },
19758        brushSymbol: function (ctx, style) {
19759            var y = style.y + style.height / 4;
19760            ctx.save();
19761            var chainPoint = style.chainPoint;
19762            var curPoint;
19763            for (var idx = 0, l = chainPoint.length; idx < l; idx++) {
19764                curPoint = chainPoint[idx];
19765                if (curPoint.symbol != 'none') {
19766                    ctx.beginPath();
19767                    var symbolSize = curPoint.symbolSize;
19768                    IconShape.prototype.buildPath(ctx, {
19769                        iconType: curPoint.symbol,
19770                        x: curPoint.x - symbolSize,
19771                        y: y - symbolSize,
19772                        width: symbolSize * 2,
19773                        height: symbolSize * 2,
19774                        n: curPoint.n
19775                    });
19776                    ctx.fillStyle = curPoint.isEmpty ? '#fff' : style.strokeColor;
19777                    ctx.closePath();
19778                    ctx.fill();
19779                    ctx.stroke();
19780                }
19781                if (curPoint.showLabel) {
19782                    ctx.font = curPoint.textFont;
19783                    ctx.fillStyle = curPoint.textColor;
19784                    ctx.textAlign = curPoint.textAlign;
19785                    ctx.textBaseline = curPoint.textBaseline;
19786                    if (curPoint.rotation) {
19787                        ctx.save();
19788                        this._updateTextTransform(ctx, curPoint.rotation);
19789                        ctx.fillText(curPoint.name, curPoint.textX, curPoint.textY);
19790                        ctx.restore();
19791                    } else {
19792                        ctx.fillText(curPoint.name, curPoint.textX, curPoint.textY);
19793                    }
19794                }
19795            }
19796            ctx.restore();
19797        },
19798        _updateTextTransform: function (ctx, rotation) {
19799            var _transform = matrix.create();
19800            matrix.identity(_transform);
19801            if (rotation[0] !== 0) {
19802                var originX = rotation[1] || 0;
19803                var originY = rotation[2] || 0;
19804                if (originX || originY) {
19805                    matrix.translate(_transform, _transform, [
19806                        -originX,
19807                        -originY
19808                    ]);
19809                }
19810                matrix.rotate(_transform, _transform, rotation[0]);
19811                if (originX || originY) {
19812                    matrix.translate(_transform, _transform, [
19813                        originX,
19814                        originY
19815                    ]);
19816                }
19817            }
19818            ctx.transform.apply(ctx, _transform);
19819        },
19820        isCover: function (x, y) {
19821            var rect = this.style;
19822            if (x >
19822= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height) {
19823                return true;
19824            } else {
19825                return false;
19826            }
19827        }
19828    };
19829    zrUtil.inherits(Chain, Base);
19830    return Chain;
19831});define('zrender/shape/Ring', [
19832    'require',
19833    './Base',
19834    '../tool/util'
19835], function (require) {
19836    var Base = require('./Base');
19837    var Ring = function (options) {
19838        Base.call(this, options);
19839    };
19840    Ring.prototype = {
19841        type: 'ring',
19842        buildPath: function (ctx, style) {
19843            ctx.arc(style.x, style.y, style.r, 0, Math.PI * 2, false);
19844            ctx.moveTo(style.x + style.r0, style.y);
19845            ctx.arc(style.x, style.y, style.r0, 0, Math.PI * 2, true);
19846            return;
19847        },
19848        getRect: function (style) {
19849            if (style.__rect) {
19850                return style.__rect;
19851            }
19852            var lineWidth;
19853            if (style.brushType == 'stroke' || style.brushType == 'fill') {
19854                lineWidth = style.lineWidth || 1;
19855            } else {
19856                lineWidth = 0;
19857            }
19858            style.__rect = {
19859                x: Math.round(style.x - style.r - lineWidth / 2),
19860                y: Math.round(style.y - style.r - lineWidth / 2),
19861                width: style.r * 2 + lineWidth,
19862                height: style.r * 2 + lineWidth
19863            };
19864            return style.__rect;
19865        }
19866    };
19867    require('../tool/util').inherits(Ring, Base);
19868    return Ring;
19869});define('echarts/component/axis', [
19870    'require',
19871    './base',
19872    'zrender/shape/Line',
19873    '../config',
19874    '../util/ecData',
19875    'zrender/tool/util',
19876    'zrender/tool/color',
19877    './categoryAxis',
19878    './valueAxis',
19879    '../component'
19880], function (require) {
19881    var Base = require('./base');
19882    var LineShape = require('zrender/shape/Line');
19883    var ecConfig = require('../config');
19884    var ecData = require('../util/ecData');
19885    var zrUtil = require('zrender/tool/util');
19886    var zrColor = require('zrender/tool/color');
19887    function Axis(ecTheme, messageCenter, zr, option, myChart, axisType) {
19888        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
19889        this.axisType = axisType;
19890        this._axisList = [];
19891        this.refresh(option);
19892    }
19893    Axis.prototype = {
19894        type: ecConfig.COMPONENT_TYPE_AXIS,
19895        axisBase: {
19896            _buildAxisLine: function () {
19897                var lineWidth = this.option.axisLine.lineStyle.width;
19898                var halfLineWidth = lineWidth / 2;
19899                var axShape = {
19900                    _axisShape: 'axisLine',
19901                    zlevel: this.getZlevelBase(),
19902                    z: this.getZBase() + 3,
19903                    hoverable: false
19904                };
19905                var grid = this.grid;
19906                switch (this.option.position) {
19907                case 'left':
19908                    axShape.style = {
19909                        xStart: grid.getX() - halfLineWidth,
19910                        yStart: grid.getYend(),
19911                        xEnd: grid.getX() - halfLineWidth,
19912                        yEnd: grid.getY(),
19913                        lineCap: 'round'
19914                    };
19915                    break;
19916                case 'right':
19917                    axShape.style = {
19918                        xStart: grid.getXend() + halfLineWidth,
19919                        yStart: grid.getYend(),
19920                        xEnd: grid.getXend() + halfLineWidth,
19921                        yEnd: grid.getY(),
19922                        lineCap: 'round'
19923                    };
19924                    break;
19925                case 'bottom':
19926                    axShape.style = {
19927                        xStart: grid.getX(),
19928                        yStart: grid.getYend() + halfLineWidth,
19929                        xEnd: grid.getXend(),
19930                        yEnd: grid.getYend() + halfLineWidth,
19931                        lineCap: 'round'
19932                    };
19933                    break;
19934                case 'top':
19935                    axShape.style = {
19936                        xStart: grid.getX(),
19937                        yStart: grid.getY() - halfLineWidth,
19938                        xEnd: grid.getXend(),
19939                        yEnd: grid.getY() - halfLineWidth,
19940                        lineCap: 'round'
19941                    };
19942                    break;
19943                }
19944                var style = axShape.style;
19945                if (this.option.name !== '') {
19946                    style.text = this.option.name;
19947                    style.textPosition = this.option.nameLocation;
19948                    style.textFont = this.getFont(this.option.nameTextStyle);
19949                    if (this.option.nameTextStyle.align) {
19950                        style.textAlign = this.option.nameTextStyle.align;
19951                    }
19952                    if (this.option.nameTextStyle.baseline) {
19953                        style.textBaseline = this.option.nameTextStyle.baseline;
19954                    }
19955                    if (this.option.nameTextStyle.color) {
19956                        style.textColor = this.option.nameTextStyle.color;
19957                    }
19958                }
19959                style.strokeColor = this.option.axisLine.lineStyle.color;
19960                style.lineWidth = lineWidth;
19961                if (this.isHorizontal()) {
19962                    style.yStart = style.yEnd = this.subPixelOptimize(style.yEnd, lineWidth);
19963                } else {
19964                    style.xStart = style.xEnd = this.subPixelOptimize(style.xEnd, lineWidth);
19965                }
19966                style.lineType = this.option.axisLine.lineStyle.type;
19967                axShape = new LineShape(axShape);
19968                this.shapeList.push(axShape);
19969            },
19970            _axisLabelClickable: function (clickable, axShape) {
19971                if (clickable) {
19972                    ecData.pack(axShape, undefined, -1, undefined, -1, axShape.style.text);
19973                    axShape.hoverable = true;
19974                    axShape.clickable = true;
19975                    axShape.highlightStyle = {
19976                        color: zrColor.lift(axShape.style.color, 1),
19977                        brushType: 'fill'
19978                    };
19979                    return axShape;
19980                } else {
19981                    return axShape;
19982                }
19983            },
19984            refixAxisShape: function (zeroX, zeroY) {
19985                if (!this.option.axisLine.onZero) {
19986                    return;
19987                }
19988                var tickLength;
19989                if (this.isHorizontal() && zeroY != null) {
19990                    for (var i = 0, l = this.shapeList.length; i < l; i++) {
19991                        if (this.shapeList[i]._axisShape === 'axisLine') {
19992                            this.shapeList[i].style.yStart = this.shapeList[i].style.yEnd = this.subPixelOptimize(zeroY, this.shapeList[i].stylelineWidth);
19993                            this.zr.modShape(this.shapeList[i].id);
19994                        } else if (this.shapeList[i]._axisShape === 'axisTick') {
19995                            tickLength = this.shapeList[i].style.yEnd - this.shapeList[i].style.yStart;
19996                            this.shapeList[i].style.yStart = zeroY - tickLength;
19997                            this.shapeList[i].style.yEnd = zeroY;
19998                            this.zr.modShape(this.shapeList[i].id);
19999                        }
20000                    }
20001                }
20002                if (!this.isHorizontal() && zeroX != null) {
20003                    for (var i = 0, l = this.shapeList.length; i < l; i++) {
20004                        if (this.shapeList[i]._axisShape === 'axisLine') {
20005                            this.shapeList[i].style.xStart = this.shapeList[i].style.xEnd = this.subPixelOptimize(zeroX, this.shapeList[i].stylelineWidth);
20006                            this.zr.modShape(this.shapeList[i].id);
20007                        } else if (this.shapeList[i]._axisShape === 'axisTick') {
20008                            tickLength = this.shapeList[i].style.xEnd - this.shapeList[i].style.xStart;
20009                            this.shapeList[i].style.xStart = zeroX;
20010                            this.shapeList[i].style.xEnd = zeroX + tickLength;
20011                            this.zr.modShape(this.shapeList[i].id);
20012                        }
20013                    }
20014                }
20015            },
20016            getPosition: function () {
20017                return this.option.position;
20018            },
20019            isHorizontal: function () {
20020                return this.option.position === 'bottom' || this.option.position === 'top';
20021            }
20022        },
20023        reformOption: function (opt) {
20024            if (!opt || opt instanceof Array && opt.length === 0) {
20025                opt = [{ type: ecConfig.COMPONENT_TYPE_AXIS_VALUE }];
20026            } else if (!(opt instanceof Array)) {
20027                opt = [opt];
20028            }
20029            if (opt.length > 2) {
20030                opt = [
20031                    opt[0],
20032                    opt[1]
20033                ];
20034            }
20035            if (this.axisType === 'xAxis') {
20036                if (!opt[0].position || opt[0].position != 'bottom' && opt[0].position != 'top') {
20037                    opt[0].position = 'bottom';
20038                }
20039                if (opt.length > 1) {
20040                    opt[1].position = opt[0].position === 'bottom' ? 'top' : 'bottom';
20041                }
20042                for (var i = 0, l = opt.length; i < l; i++) {
20043                    opt[i].type = opt[i].type || 'category';
20044                    opt[i].xAxisIndex = i;
20045                    opt[i].yAxisIndex = -1;
20046                }
20047            } else {
20048                if (!opt[0].position || opt[0].position != 'left' && opt[0].position != 'right') {
20049                    opt[0].position = 'left';
20050                }
20051                if (opt.length > 1) {
20052                    opt[1].position = opt[0].position === 'left' ? 'right' : 'left';
20053                }
20054                for (var i = 0, l = opt.length; i < l; i++) {
20055                    opt[i].type = opt[i].type || 'value';
20056                    opt[i].xAxisIndex = -1;
20057                    opt[i].yAxisIndex = i;
20058                }
20059            }
20060            return opt;
20061        },
20062        refresh: function (newOption) {
20063            var axisOption;
20064            if (newOption) {
20065                this.option = newOption;
20066                if (this.axisType === 'xAxis') {
20067                    this.option.xAxis = this.reformOption(newOption.xAxis);
20068                    axisOption = this.option.xAxis;
20069                } else {
20070                    this.option.yAxis = this.reformOption(newOption.yAxis);
20071                    axisOption = this.option.yAxis;
20072                }
20073                this.series = newOption.series;
20074            }
20075            var CategoryAxis = require('./categoryAxis');
20076            var ValueAxis = require('./valueAxis');
20077            var len = Math.max(axisOption && axisOption.length || 0, this._axisList.length);
20078            for (var i = 0; i < len; i++) {
20079                if (this._axisList[i] && newOption && (!axisOption[i] || this._axisList[i].type != axisOption[i].type)) {
20080                    this._axisList[i].dispose && this._axisList[i].dispose();
20081                    this._axisList[i] = false;
20082                }
20083                if (this._axisList[i]) {
20084                    this._axisList[i].refresh && this._axisList[i].refresh(axisOption ? axisOption[i] : false, this.series);
20085                } else if (axisOption && axisOption[i]) {
20086                    this._axisList[i] = axisOption[i].type === 'category' ? new CategoryAxis(this.ecTheme, this.messageCenter, this.zr, axisOption[i], this.myChart, this.axisBase) : new ValueAxis(this.ecTheme, this.messageCenter, this.zr, axisOption[i], this.myChart, this.axisBase, this.series);
20087                }
20088            }
20089        },
20090        getAxis: function (idx) {
20091            return this._axisList[idx];
20092        },
20093        getAxisCount: function () {
20094            return this._axisList.length;
20095        },
20096        clear: function () {
20097            for (var i = 0, l = this._axisList.length; i < l; i++) {
20098                this._axisList[i].dispose && this._axisList[i].dispose();
20099            }
20100            this._axisList = [];
20101        }
20102    };
20103    zrUtil.inherits(Axis, Base);
20104    require('../component').define('axis', Axis);
20105    return Axis;
20106});define('echarts/component/grid', [
20107    'require',
20108    './base',
20109    'zrender/shape/Rectangle',
20110    '../config',
20111    'zrender/tool/util',
20112    '../component'
20113], function (require) {
20114    var Base = require('./base');
20115    var RectangleShape = require('zrender/shape/Rectangle');
20116    var ecConfig = require('../config');
20117    ecConfig.grid = {
20118        zlevel: 0,
20119        z: 0,
20120        x: 80,
20121        y: 60,
20122        x2: 80,
20123        y2: 60,
20124        backgroundColor: 'rgba(0,0,0,0)',
20125        borderWidth: 1,
20126        borderColor: '#ccc'
20127    };
20128    var zrUtil = require('zrender/tool/util');
20129    function Grid(ecTheme, messageCenter, zr, option, myChart) {
20130        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
20131        this.refresh(option);
20132    }
20133    Grid.prototype = {
20134        type: ecConfig.COMPONENT_TYPE_GRID,
20135        getX: function () {
20136            return this._x;
20137        },
20138        getY: function () {
20139            return this._y;
20140        },
20141        getWidth: function () {
20142            return this._width;
20143        },
20144        getHeight: function () {
20145            return this._height;
20146        },
20147        getXend: function () {
20148            return this._x + this._width;
20149        },
20150        getYend: function () {
20151            return this._y + this._height;
20152        },
20153        getArea: function () {
20154            return {
20155                x: this._x,
20156                y: this._y,
20157                width: this._width,
20158                height: this._height
20159            };
20160        },
20161        getBbox: function () {
20162            return [
20163                [
20164                    this._x,
20165                    this._y
20166                ],
20167                [
20168                    this.getXend(),
20169                    this.getYend()
20170                ]
20171            ];
20172        },
20173        refixAxisShape: function (component) {
20174            var zeroX;
20175            var zeroY;
20176            var axisList = component.xAxis._axisList.concat(component.yAxis ? component.yAxis._axisList : []);
20177            var len = axisList.length;
20178            var axis;
20179            while (len--) {
20180                axis = axisList[len];
20181                if (axis.type == ecConfig.COMPONENT_TYPE_AXIS_VALUE && axis._min < 0 && axis._max >= 0) {
20182                    axis.isHorizontal() ? zeroX = axis.getCoord(0) : zeroY = axis.getCoord(0);
20183                }
20184            }
20185            if (typeof zeroX != 'undefined' || typeof zeroY != 'undefined') {
20186                len = axisList.length;
20187                while (len--) {
20188                    axisList[len].refixAxisShape(zeroX, zeroY);
20189                }
20190            }
20191        },
20192        refresh: function (newOption) {
20193            if (newOption || this._zrWidth != this.zr.getWidth() || this._zrHeight != this.zr.getHeight()) {
20194                this.clear();
20195                this.option = newOption || this.option;
20196                this.option.grid = this.reformOption(this.option.grid);
20197                var gridOption = this.option.grid;
20198                this._zrWidth = this.zr.getWidth();
20199                this._zrHeight = this.zr.getHeight();
20200                this._x = this.parsePercent(gridOption.x, this._zrWidth);
20201                this._y = this.parsePercent(gridOption.y, this._zrHeight);
20202                var x2 = this.parsePercent(gridOption.x2, this._zrWidth);
20203                var y2 = this.parsePercent(gridOption.y2, this._zrHeight);
20204                if (typeof gridOption.width == 'undefined') {
20205                    this._width = this._zrWidth - this._x - x2;
20206                } else {
20207                    this._width = this.parsePercent(gridOption.width, this._zrWidth);
20208                }
20209                this._width = this._width <= 0 ? 10 : this._width;
20210                if (typeof gridOption.height == 'undefined') {
20211                    this._height = this._zrHeight - this._y - y2;
20212                } else {
20213                    this._height = this.parsePercent(gridOption.height, this._zrHeight);
20214                }
20215                this._height = this._height <= 0 ? 10 : this._height;
20216                this._x = this.subPixelOptimize(this._x, gridOption.borderWidth);
20217                this._y = this.subPixelOptimize(this._y, gridOption.borderWidth);
20218                this.shapeList.push(new RectangleShape({
20219                    zlevel: this.getZlevelBase(),
20220                    z: this.getZBase(),
20221                    hoverable: false,
20222                    style: {
20223                        x: this._x,
20224                        y: this._y,
20225                        width: this._width,
20226                        height: this._height,
20227                        brushType: gridOption.borderWidth > 0 ? 'both' : 'fill',
20228                        color: gridOption.backgroundColor,
20229                        strokeColor: gridOption.borderColor,
20230                        lineWidth: gridOption.borderWidth
20231                    }
20232                }));
20233                this.zr.addShape(this.shapeList[0]);
20234            }
20235        }
20236    };
20237    zrUtil.inherits(Grid, Base);
20238    require('../component').define('grid', Grid);
20239    return Grid;
20240});define('echarts/component/dataZoom', [
20241    'require',
20242    './base',
20243    'zrender/shape/Rectangle',
20244    'zrender/shape/Polygon',
20245    '../util/shape/Icon',
20246    '../config',
20247    '../util/date',
20248    'zrender/tool/util',
20249    '../component'
20250], function (require) {
20251    var Base = require('./base');
20252    var RectangleShape = require('zrender/shape/Rectangle');
20253    var PolygonShape = require('zrender/shape/Polygon');
20254    var IconShape = require('../util/shape/Icon');
20255    var ecConfig = require('../config');
20256    ecConfig.dataZoom = {
20257        zlevel: 0,
20258        z: 4,
20259        show: false,
20260        orient: 'horizontal',
20261        backgroundColor: 'rgba(0,0,0,0)',
20262        dataBackgroundColor: '#eee',
20263        fillerColor: 'rgba(144,197,237,0.2)',
20264        handleColor: 'rgba(70,130,180,0.8)',
20265        handleSize: 8,
20266        showDetail: true,
20267        realtime: true
20268    };
20269    var ecDate = require('../util/date');
20270    var zrUtil = require('zrender/tool/util');
20271    function DataZoom(ecTheme, messageCenter, zr, option, myChart) {
20272        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
20273        var self = this;
20274        self._ondrift = function (dx, dy) {
20275            return self.__ondrift(this, dx, dy);
20276        };
20277        self._ondragend = function () {
20278            return self.__ondragend();
20279        };
20280        this._fillerSize = 30;
20281        this._isSilence = false;
20282        this._zoom = {};
20283        this.option.dataZoom = this.reformOption(this.option.dataZoom);
20284        this.zoomOption = this.option.dataZoom;
20285        this._handleSize = this.zoomOption.handleSize;
20286        if (!this.myChart.canvasSupported) {
20287            this.zoomOption.realtime = false;
20288        }
20289        this._location = this._getLocation();
20290        this._zoom = this._getZoom();
20291        this._backupData();
20292        if (this.option.dataZoom.show) {
20293            this._buildShape();
20294        }
20295        this._syncData();
20296    }
20297    DataZoom.prototype = {
20298        type: ecConfig.COMPONENT_TYPE_DATAZOOM,
20299        _buildShape: function () {
20300            this._buildBackground();
20301            this._buildFiller();
20302            this._buildHandle();
20303            this._buildFrame();
20304            for (var i = 0, l = this.shapeList.length; i < l; i++) {
20305                this.zr.addShape(this.shapeList[i]);
20306            }
20307            this._syncFrameShape();
20308        },
20309        _getLocation: function () {
20310            var x;
20311            var y;
20312            var width;
20313            var height;
20314            var grid = this.component.grid;
20315            if (this.zoomOption.orient == 'horizontal') {
20316                width = this.zoomOption.width || grid.getWidth();
20317                height = this.zoomOption.height || this._fillerSize;
20318                x = this.zoomOption.x != null ? this.zoomOption.x : grid.getX();
20319                y = this.zoomOption.y != null ? this.zoomOption.y : this.zr.getHeight() - height - 2;
20320            } else {
20321                width = this.zoomOption.width || this._fillerSize;
20322                height = this.zoomOption.height || grid.getHeight();
20323                x = this.zoomOption.x != null ? this.zoomOption.x : 2;
20324                y = this.zoomOption.y != null ? this.zoomOption.y : grid.getY();
20325            }
20326            return {
20327                x: x,
20328                y: y,
20329                width: width,
20330                height: height
20331            };
20332        },
20333        _getZoom: function () {
20334            var series = this.option.series;
20335            var xAxis = this.option.xAxis;
20336            if (xAxis && !(xAxis instanceof Array)) {
20337                xAxis = [xAxis];
20338                this.option.xAxis = xAxis;
20339            }
20340            var yAxis = this.option.yAxis;
20341            if (yAxis && !(yAxis instanceof Array)) {
20342                yAxis = [yAxis];
20343                this.option.yAxis = yAxis;
20344            }
20345            var zoomSeriesIndex = [];
20346            var xAxisIndex;
20347            var yAxisIndex;
20348            var zOptIdx = this.zoomOption.xAxisIndex;
20349            if (xAxis && zOptIdx == null) {
20350                xAxisIndex = [];
20351                for (var i = 0, l = xAxis.length; i < l; i++) {
20352                    if (xAxis[i].type == 'category' || xAxis[i].type == null) {
20353                        xAxisIndex.push(i);
20354                    }
20355                }
20356            } else {
20357                if (zOptIdx instanceof Array) {
20358                    xAxisIndex = zOptIdx;
20359                } else if (zOptIdx != null) {
20360                    xAxisIndex = [zOptIdx];
20361                } else {
20362                    xAxisIndex = [];
20363                }
20364            }
20365            zOptIdx = this.zoomOption.yAxisIndex;
20366            if (yAxis && zOptIdx == null) {
20367                yAxisIndex = [];
20368                for (var i = 0, l = yAxis.length; i < l; i++) {
20369                    if (yAxis[i].type == 'category') {
20370                        yAxisIndex.push(i);
20371                    }
20372                }
20373            } else {
20374                if (zOptIdx instanceof Array) {
20375                    yAxisIndex = zOptIdx;
20376                } else if (zOptIdx != null) {
20377                    yAxisIndex = [zOptIdx];
20378                } else {
20379                    yAxisIndex = [];
20380                }
20381            }
20382            var serie;
20383            for (var i = 0, l = series.length; i < l; i++) {
20384                serie = series[i];
20385                if (serie.type != ecConfig.CHART_TYPE_LINE && serie.type != ecConfig.CHART_TYPE_BAR && serie.type != ecConfig.CHART_TYPE_SCATTER && serie.type != ecConfig.CHART_TYPE_K) {
20386                    continue;
20387                }
20388                for (var j = 0, k = xAxisIndex.length; j < k; j++) {
20389                    if (xAxisIndex[j] == (serie.xAxisIndex || 0)) {
20390                        zoomSeriesIndex.push(i);
20391                        break;
20392                    }
20393                }
20394                for (var j = 0, k = yAxisIndex.length; j < k; j++) {
20395                    if (yAxisIndex[j] == (serie.yAxisIndex || 0)) {
20396                        zoomSeriesIndex.push(i);
20397                        break;
20398                    }
20399                }
20400                if (this.zoomOption.xAxisIndex == null && this.zoomOption.yAxisIndex == null && serie.data && this.getDataFromOption(serie.data[0]) instanceof Array && (serie.type == ecConfig.CHART_TYPE_SCATTER || serie.type == ecConfig.CHART_TYPE_LINE || serie.type == ecConfig.CHART_TYPE_BAR)) {
20401                    zoomSeriesIndex.push(i);
20402                }
20403            }
20404            var start = this._zoom.start != null ? this._zoom.start : this.zoomOption.start != null ? this.zoomOption.start : 0;
20405            var end = this._zoom.end != null ? this._zoom.end : this.zoomOption.end != null ? this.zoomOption.end : 100;
20406            if (start > end) {
20407                start = start + end;
20408                end = start - end;
20409                start = start - end;
20410            }
20411            var size = Math.round((end - start) / 100 * (this.zoomOption.orient == 'horizontal' ? this._location.width : this._location.height));
20412            return {
20413                start: start,
20414                end: end,
20415                start2: 0,
20416                end2: 100,
20417                size: size,
20418                xAxisIndex: xAxisIndex,
20419                yAxisIndex: yAxisIndex,
20420                seriesIndex: zoomSeriesIndex,
20421                scatterMap: this._zoom.scatterMap || {}
20422            };
20423        },
20424        _backupData: function () {
20425            this._originalData = {
20426                xAxis: {},
20427                yAxis: {},
20428                series: {}
20429            };
20430            var xAxis = this.option.xAxis;
20431            var xAxisIndex = this._zoom.xAxisIndex;
20432            for (var i = 0, l = xAxisIndex.length; i < l; i++) {
20433                this._originalData.xAxis[xAxisIndex[i]] = xAxis[xAxisIndex[i]].data;
20434            }
20435            var yAxis = this.option.yAxis;
20436            var yAxisIndex = this._zoom.yAxisIndex;
20437            for (var i = 0, l = yAxisIndex.length; i < l; i++) {
20438                this._originalData.yAxis[yAxisIndex[i]] = yAxis[yAxisIndex[i]].data;
20439            }
20440            var series = this.option.series;
20441            var seriesIndex = this._zoom.seriesIndex;
20442            var serie;
20443            for (var i = 0, l = seriesIndex.length; i < l; i++) {
20444                serie = series[seriesIndex[i]];
20445                this._originalData.series[seriesIndex[i]] = serie.data;
20446                if (serie.data && this.getDataFromOption(serie.data[0]) instanceof Array && (serie.type == ecConfig.CHART_TYPE_SCATTER || serie.type == ecConfig.CHART_TYPE_LINE || serie.type == ecConfig.CHART_TYPE_BAR)) {
20447                    this._backupScale();
20448                    this._calculScatterMap(seriesIndex[i]);
20449                }
20450            }
20451        },
20452        _calculScatterMap: function (seriesIndex) {
20453            this._zoom.scatterMap = this._zoom.scatterMap || {};
20454            this._zoom.scatterMap[seriesIndex] = this._zoom.scatterMap[seriesIndex] || {};
20455            var componentLibrary = require('../component');
20456            var Axis = componentLibrary.get('axis');
20457            var axisOption = zrUtil.clone(this.option.xAxis);
20458            if (axisOption[0].type == 'category') {
20459                axisOption[0].type = 'value';
20460            }
20461            if (axisOption[1] && axisOption[1].type == 'category') {
20462                axisOption[1].type = 'value';
20463            }
20464            var vAxis = new Axis(this.ecTheme, null, false, {
20465                xAxis: axisOption,
20466                series: this.option.series
20467            }, this, 'xAxis');
20468            var axisIndex = this.option.series[seriesIndex].xAxisIndex || 0;
20469            this._zoom.scatterMap[seriesIndex].x = vAxis.getAxis(axisIndex).getExtremum();
20470            vAxis.dispose();
20471            axisOption = zrUtil.clone(this.option.yAxis);
20472            if (axisOption[0].type == 'category') {
20473                axisOption[0].type = 'value';
20474            }
20475            if (axisOption[1] && axisOption[1].type == 'category') {
20476                axisOption[1].type = 'value';
20477            }
20478            vAxis = new Axis(this.ecTheme, null, false, {
20479                yAxis: axisOption,
20480                series: this.option.series
20481            }, this, 'yAxis');
20482            axisIndex = this.option.series[seriesIndex].yAxisIndex || 0;
20483            this._zoom.scatterMap[seriesIndex].y = vAxis.getAxis(axisIndex).getExtremum();
20484            vAxis.dispose();
20485        },
20486        _buildBackground: function () {
20487            var width = this._location.width;
20488            var height = this._location.height;
20489            this.shapeList.push(new RectangleShape({
20490                zlevel: this.getZlevelBase(),
20491                z: this.getZBase(),
20492                hoverable: false,
20493                style: {
20494                    x: this._location.x,
20495                    y: this._location.y,
20496                    width: width,
20497                    height: height,
20498                    color: this.zoomOption.backgroundColor
20499                }
20500            }));
20501            var maxLength = 0;
20502            var xAxis = this._originalData.xAxis;
20503            var xAxisIndex = this._zoom.xAxisIndex;
20504            for (var i = 0, l = xAxisIndex.length; i < l; i++) {
20505                maxLength = Math.max(maxLength, xAxis[xAxisIndex[i]].length);
20506            }
20507            var yAxis = this._originalData.yAxis;
20508            var yAxisIndex = this._zoom.yAxisIndex;
20509            for (var i = 0, l = yAxisIndex.length; i < l; i++) {
20510                maxLength = Math.max(maxLength, yAxis[yAxisIndex[i]].length);
20511            }
20512            var seriesIndex = this._zoom.seriesIndex[0];
20513            var data = this._originalData.series[seriesIndex];
20514            var maxValue = Number.MIN_VALUE;
20515            var minValue = Number.MAX_VALUE;
20516            var value;
20517            for (var i = 0, l = data.length; i < l; i++) {
20518                value = this.getDataFromOption(data[i], 0);
20519                if (this.option.series[seriesIndex].type == ecConfig.CHART_TYPE_K) {
20520                    value = value[1];
20521                }
20522                if (isNaN(value)) {
20523                    value = 0;
20524                }
20525                maxValue = Math.max(maxValue, value);
20526                minValue = Math.min(minValue, value);
20527            }
20528            var valueRange = maxValue - minValue;
20529            var pointList = [];
20530            var x = width / (maxLength - (maxLength > 1 ? 1 : 0));
20531            var y = height / (maxLength - (maxLength > 1 ? 1 : 0));
20532            var step = 1;
20533            if (this.zoomOption.orient == 'horizontal' && x < 1) {
20534                step = Math.floor(maxLength * 3 / width);
20535            } else if (this.zoomOption.orient == 'vertical' && y < 1) {
20536                step = Math.floor(maxLength * 3 / height);
20537            }
20538            for (var i = 0, l = maxLength; i < l; i += step) {
20539                value = this.getDataFromOption(data[i], 0);
20540                if (this.option.series[seriesIndex].type == ecConfig.CHART_TYPE_K) {
20541                    value = value[1];
20542                }
20543                if (isNaN(value)) {
20544                    value = 0;
20545                }
20546                if (this.zoomOption.orient == 'horizontal') {
20547                    pointList.push([
20548                        this._location.x + x * i,
20549                        this._location.y + height - 1 - Math.round((value - minValue) / valueRange * (height - 10))
20550                    ]);
20551                } else {
20552                    pointList.push([
20553                        this._location.x + 1 + Math.round((value - minValue) / valueRange * (width - 10)),
20554                        this._location.y + y * (l - i - 1)
20555                    ]);
20556                }
20557            }
20558            if (this.zoomOption.orient == 'horizontal') {
20559                pointList.push([
20560                    this._location.x + width,
20561                    this._location.y + height
20562                ]);
20563                pointList.push([
20564                    this._location.x,
20565                    this._location.y + height
20566                ]);
20567            } else {
20568                pointList.push([
20569                    this._location.x,
20570                    this._location.y
20571                ]);
20572                pointList.push([
20573                    this._location.x,
20574                    this._location.y + height
20575                ]);
20576            }
20577            this.shapeList.push(new PolygonShape({
20578                zlevel: this.getZlevelBase(),
20579                z: this.getZBase(),
20580                style: {
20581                    pointList: pointList,
20582                    color: this.zoomOption.dataBackgroundColor
20583                },
20584                hoverable: false
20585            }));
20586        },
20587        _buildFiller: function () {
20588            this._fillerShae = {
20589                zlevel: this.getZlevelBase(),
20590                z: this.getZBase(),
20591                draggable: true,
20592                ondrift: this._ondrift,
20593                ondragend: this._ondragend,
20594                _type: 'filler'
20595            };
20596            if (this.zoomOption.orient == 'horizontal') {
20597                this._fillerShae.style = {
20598                    x: this._location.x + Math.round(this._zoom.start / 100 * this._location.width) + this._handleSize,
20599                    y: this._location.y,
20600                    width: this._zoom.size - this._handleSize * 2,
20601                    height: this._location.height,
20602                    color: this.zoomOption.fillerColor,
20603                    text: ':::',
20604                    textPosition: 'inside'
20605                };
20606            } else {
20607                this._fillerShae.style = {
20608                    x: this._location.x,
20609                    y: this._location.y + Math.round(this._zoom.start / 100 * this._location.height) + this._handleSize,
20610                    width: this._location.width,
20611                    height: this._zoom.size - this._handleSize * 2,
20612                    color: this.zoomOption.fillerColor,
20613                    text: '::',
20614                    textPosition: 'inside'
20615                };
20616            }
20617            this._fillerShae.highlightStyle = {
20618                brushType: 'fill',
20619                color: 'rgba(0,0,0,0)'
20620            };
20621            this._fillerShae = new RectangleShape(this._fillerShae);
20622            this.shapeList.push(this._fillerShae);
20623        },
20624        _buildHandle: function () {
20625            var detail = this.zoomOption.showDetail ? this._getDetail() : {
20626                start: '',
20627                end: ''
20628            };
20629            this._startShape = {
20630                zlevel: this.getZlevelBase(),
20631                z: this.getZBase(),
20632                draggable: true,
20633                style: {
20634                    iconType: 'rectangle',
20635                    x: this._location.x,
20636                    y: this._location.y,
20637                    width: this._handleSize,
20638                    height: this._handleSize,
20639                    color: this.zoomOption.handleColor,
20640                    text: '=',
20641                    textPosition: 'inside'
20642                },
20643                highlightStyle: {
20644                    text: detail.start,
20645                    brushType: 'fill',
20646                    textPosition: 'left'
20647                },
20648                ondrift: this._ondrift,
20649                ondragend: this._ondragend
20650            };
20651            if (this.zoomOption.orient == 'horizontal') {
20652                this._startShape.style.height = this._location.height;
20653                this._endShape = zrUtil.clone(this._startShape);
20654                this._startShape.style.x = this._fillerShae.style.x - this._handleSize, this._endShape.style.x = this._fillerShae.style.x + this._fillerShae.style.width;
20655                this._endShape.highlightStyle.text = detail.end;
20656                this._endShape.highlightStyle.textPosition = 'right';
20657            } else {
20658                this._startShape.style.width = this._location.width;
20659                this._endShape = zrUtil.clone(this._startShape);
20660                this._startShape.style.y = this._fillerShae.style.y + this._fillerShae.style.height;
20661                this._startShape.highlightStyle.textPosition = 'bottom';
20662                this._endShape.style.y = this._fillerShae.style.y - this._handleSize;
20663                this._endShape.highlightStyle.text = detail.end;
20664                this._endShape.highlightStyle.textPosition = 'top';
20665            }
20666            this._startShape = new IconShape(this._startShape);
20667            this._endShape = new IconShape(this._endShape);
20668            this.shapeList.push(this._startShape);
20669            this.shapeList.push(this._endShape);
20670        },
20671        _buildFrame: function () {
20672            var x = this.subPixelOptimize(this._location.x, 1);
20673            var y = this.subPixelOptimize(this._location.y, 1);
20674            this._startFrameShape = {
20675                zlevel: this.getZlevelBase(),
20676                z: this.getZBase(),
20677                hoverable: false,
20678                style: {
20679                    x: x,
20680                    y: y,
20681                    width: this._location.width - (x > this._location.x ? 1 : 0),
20682                    height: this._location.height - (y > this._location.y ? 1 : 0),
20683                    lineWidth: 1,
20684                    brushType: 'stroke',
20685                    strokeColor: this.zoomOption.handleColor
20686                }
20687            };
20688            this._endFrameShape = zrUtil.clone(this._startFrameShape);
20689            this._startFrameShape = new RectangleShape(this._startFrameShape);
20690            this._endFrameShape = new RectangleShape(this._endFrameShape);
20691            this.shapeList.push(this._startFrameShape);
20692            this.shapeList.push(this._endFrameShape);
20693            return;
20694        },
20695        _syncHandleShape: function () {
20696            if (this.zoomOption.orient == 'horizontal') {
20697                this._startShape.style.x = this._fillerShae.style.x - this._handleSize;
20698                this._endShape.style.x = this._fillerShae.style.x + this._fillerShae.style.width;
20699                this._zoom.start = (this._startShape.style.x - this._location.x) / this._location.width * 100;
20700                this._zoom.end = (this._endShape.style.x + this._handleSize - this._location.x) / this._location.width * 100;
20701            } else {
20702                this._startShape.style.y = this._fillerShae.style.y + this._fillerShae.style.height;
20703                this._endShape.style.y = this._fillerShae.style.y - this._handleSize;
20704                this._zoom.start = (this._location.y + this._location.height - this._startShape.style.y) / this._location.height * 100;
20705                this._zoom.end = (this._location.y + this._location.height - this._endShape.style.y - this._handleSize) / this._location.height * 100;
20706            }
20707            this.zr.modShape(this._startShape.id);
20708            this.zr.modShape(this._endShape.id);
20709            this._syncFrameShape();
20710            this.zr.refreshNextFrame();
20711        },
20712        _syncFillerShape: function () {
20713            var a;
20714            var b;
20715            if (this.zoomOption.orient == 'horizontal') {
20716                a = this._startShape.style.x;
20717                b = this._endShape.style.x;
20718                this._fillerShae.style.x = Math.min(a, b) + this._handleSize;
20719                this._fillerShae.style.width = Math.abs(a - b) - this._handleSize;
20720                this._zoom.start = (Math.min(a, b) - this._location.x) / this._location.width * 100;
20721                this._zoom.end = (Math.max(a, b) + this._handleSize - this._location.x) / this._location.width * 100;
20722            } else {
20723                a = this._startShape.style.y;
20724                b = this._endShape.style.y;
20725                this._fillerShae.style.y = Math.min(a, b) + this._handleSize;
20726                this._fillerShae.style.height = Math.abs(a - b) - this._handleSize;
20727                this._zoom.start = (this._location.y + this._location.height - Math.max(a, b)) / this._location.height * 100;
20728                this._zoom.end = (this._location.y + this._location.height - Math.min(a, b) - this._handleSize) / this._location.height * 100;
20729            }
20730            this.zr.modShape(this._fillerShae.id);
20731            this._syncFrameShape();
20732            this.zr.refreshNextFrame();
20733        },
20734        _syncFrameShape: function () {
20735            if (this.zoomOption.orient == 'horizontal') {
20736                this._startFrameShape.style.width = this._fillerShae.style.x - this._location.x;
20737                this._endFrameShape.style.x = this._fillerShae.style.x + this._fillerShae.style.width;
20738                this._endFrameShape.style.width = this._location.x + this._location.width - this._endFrameShape.style.x;
20739            } else {
20740                this._startFrameShape.style.y = this._fillerShae.style.y + this._fillerShae.style.height;
20741                this._startFrameShape.style.height = this._location.y + this._location.height - this._startFrameShape.style.y;
20742                this._endFrameShape.style.height = this._fillerShae.style.y - this._location.y;
20743            }
20744            this.zr.modShape(this._startFrameShape.id);
20745            this.zr.modShape(this._endFrameShape.id);
20746        },
20747        _syncShape: function () {
20748            if (!this.zoomOption.show) {
20749                return;
20750            }
20751            if (this.zoomOption.orient == 'horizontal') {
20752                this._startShape.style.x = this._location.x + this._zoom.start / 100 * this._location.width;
20753                this._endShape.style.x = this._location.x + this._zoom.end / 100 * this._location.width - this._handleSize;
20754                this._fillerShae.style.x = this._startShape.style.x + this._handleSize;
20755                this._fillerShae.style.width = this._endShape.style.x - this._startShape.style.x - this._handleSize;
20756            } else {
20757                this._startShape.style.y = this._location.y + this._location.height - this._zoom.start / 100 * this._location.height;
20758                this._endShape.style.y = this._location.y + this._location.height - this._zoom.end / 100 * this._location.height - this._handleSize;
20759                this._fillerShae.style.y = this._endShape.style.y + this._handleSize;
20760                this._fillerShae.style.height = this._startShape.style.y - this._endShape.style.y - this._handleSize;
20761            }
20762            this.zr.modShape(this._startShape.id);
20763            this.zr.modShape(this._endShape.id);
20764            this.zr.modShape(this._fillerShae.id);
20765            this._syncFrameShape();
20766            this.zr.refresh();
20767        },
20768        _syncData: function (dispatchNow) {
20769            var target;
20770            var start;
20771            var end;
20772            var length;
20773            var data;
20774            for (var key in this._originalData) {
20775                target = this._originalData[key];
20776                for (var idx in target) {
20777                    data = target[idx];
20778                    if (data == null) {
20779                        continue;
20780                    }
20781                    length = data.length;
20782                    start = Math.floor(this._zoom.start / 100 * length);
20783                    end = Math.ceil(this._zoom.end / 100 * length);
20784                    if (!(this.getDataFromOption(data[0]) instanceof Array) || this.option[key][idx].type == ecConfig.CHART_TYPE_K) {
20785                        this.option[key][idx].data = data.slice(start, end);
20786                    } else {
20787                        this._setScale();
20788                        this.option[key][idx].data = this._synScatterData(idx, data);
20789                    }
20790                }
20791            }
20792            if (!this._isSilence && (this.zoomOption.realtime || dispatchNow)) {
20793                this.messageCenter.dispatch(ecConfig.EVENT.DATA_ZOOM, null, { zoom: this._zoom }, this.myChart);
20794            }
20795        },
20796        _synScatterData: function (seriesIndex, data) {
20797            if (this._zoom.start === 0 && this._zoom.end == 100 && this._zoom.start2 === 0 && this._zoom.end2 == 100) {
20798                return data;
20799            }
20800            var newData = [];
20801            var scale = this._zoom.scatterMap[seriesIndex];
20802            var total;
20803            var xStart;
20804            var xEnd;
20805            var yStart;
20806            var yEnd;
20807            if (this.zoomOption.orient == 'horizontal') {
20808                total = scale.x.max - scale.x.min;
20809                xStart = this._zoom.start / 100 * total + scale.x.min;
20810                xEnd = this._zoom.end / 100 * total + scale.x.min;
20811                total = scale.y.max - scale.y.min;
20812                yStart = this._zoom.start2 / 100 * total + scale.y.min;
20813                yEnd = this._zoom.end2 / 100 * total + scale.y.min;
20814            } else {
20815                total = scale.x.max - scale.x.min;
20816                xStart = this._zoom.start2 / 100 * total + scale.x.min;
20817                xEnd = this._zoom.end2 / 100 * total + scale.x.min;
20818                total = scale.y.max - scale.y.min;
20819                yStart = this._zoom.start / 100 * total + scale.y.min;
20820                yEnd = this._zoom.end / 100 * total + scale.y.min;
20821            }
20822            var dataMappingMethods;
20823            if (dataMappingMethods = scale.x.dataMappingMethods) {
20824                xStart = dataMappingMethods.coord2Value(xStart);
20825                xEnd = dataMappingMethods.coord2Value(xEnd);
20826            }
20827            if (dataMappingMethods = scale.y.dataMappingMethods) {
20828                yStart = dataMappingMethods.coord2Value(yStart);
20829                yEnd = dataMappingMethods.coord2Value(yEnd);
20830            }
20831            var value;
20832            for (var i = 0, l = data.length; i < l; i++) {
20833                value = data[i].value || data[i];
20834                if (value[0] >= xStart && value[0] <= xEnd && value[1] >= yStart && value[1] <= yEnd) {
20835                    newData.push(data[i]);
20836                }
20837            }
20838            return newData;
20839        },
20840        _setScale: function () {
20841            var needScale = this._zoom.start !== 0 || this._zoom.end !== 100 || this._zoom.start2 !== 0 || this._zoom.end2 !== 100;
20842            var axis = {
20843                xAxis: this.option.xAxis,
20844                yAxis: this.option.yAxis
20845            };
20846            for (var key in axis) {
20847                for (var i = 0, l = axis[key].length; i < l; i++) {
20848                    axis[key][i].scale = needScale || axis[key][i]._scale;
20849                }
20850            }
20851        },
20852        _backupScale: function () {
20853            var axis = {
20854                xAxis: this.option.xAxis,
20855                yAxis: this.option.yAxis
20856            };
20857            for (var key in axis) {
20858                for (var i = 0, l = axis[key].length; i < l; i++) {
20859                    axis[key][i]._scale = axis[key][i].scale;
20860                }
20861            }
20862        },
20863        _getDetail: function () {
20864            var key = [
20865                'xAxis',
20866                'yAxis'
20867            ];
20868            for (var i = 0, l = key.length; i < l; i++) {
20869                var target = this._originalData[key[i]];
20870                for (var idx in target) {
20871                    var data = target[idx];
20872                    if (data == null) {
20873                        continue;
20874                    }
20875                    var length = data.length;
20876                    var start = Math.floor(this._zoom.start / 100 * length);
20877                    var end = Math.ceil(this._zoom.end / 100 * length);
20878                    end -= end > 0 ? 1 : 0;
20879                    return {
20880                        start: this.getDataFromOption(data[start]),
20881                        end: this.getDataFromOption(data[end])
20882                    };
20883                }
20884            }
20885            key = this.zoomOption.orient == 'horizontal' ? 'xAxis' : 'yAxis';
20886            var seriesIndex = this._zoom.seriesIndex[0];
20887            var axisIndex = this.option.series[seriesIndex][key + 'Index'] || 0;
20888            var axisType = this.option[key][axisIndex].type;
20889            var min = this._zoom.scatterMap[seriesIndex][key.charAt(0)].min;
20890            var max = this._zoom.scatterMap[seriesIndex][key.charAt(0)].max;
20891            var gap = max - min;
20892            if (axisType == 'value') {
20893                return {
20894                    start: min + gap * this._zoom.start / 100,
20895                    end: min + gap * this._zoom.end / 100
20896                };
20897            } else if (axisType == 'time') {
20898                max = min + gap * this._zoom.end / 100;
20899                min = min + gap * this._zoom.start / 100;
20900                var formatter = ecDate.getAutoFormatter(min, max).formatter;
20901                return {
20902                    start: ecDate.format(formatter, min),
20903                    end: ecDate.format(formatter, max)
20904                };
20905            }
20906            return {
20907                start: '',
20908                end: ''
20909            };
20910        },
20911        __ondrift: function (shape, dx, dy) {
20912            if (this.zoomOption.zoomLock) {
20913                shape = this._fillerShae;
20914            }
20915            var detailSize = shape._type == 'filler' ? this._handleSize : 0;
20916            if (this.zoomOption.orient == 'horizontal') {
20917                if (shape.style.x + dx - detailSize <= this._location.x) {
20918                    shape.style.x = this._location.x + detailSize;
20919                } else if (shape.style.x + dx + shape.style.width + detailSize >= this._location.x + this._location.width) {
20920                    shape.style.x = this._location.x + this._location.width - shape.style.width - detailSize;
20921                } else {
20922                    shape.style.x += dx;
20923                }
20924            } else {
20925                if (shape.style.y + dy - detailSize <= this._location.y) {
20926                    shape.style.y = this._location.y + detailSize;
20927                } else if (shape.style.y + dy + shape.style.height + detailSize >= this._location.y + this._location.height) {
20928                    shape.style.y = this._location.y + this._location.height - shape.style.height - detailSize;
20929                } else {
20930                    shape.style.y += dy;
20931                }
20932            }
20933            if (shape._type == 'filler') {
20934                this._syncHandleShape();
20935            } else {
20936                this._syncFillerShape();
20937            }
20938            if (this.zoomOption.realtime) {
20939                this._syncData();
20940            }
20941            if (this.zoomOption.showDetail) {
20942                var detail = this._getDetail();
20943                this._startShape.style.text = this._startShape.highlightStyle.text = detail.start;
20944                this._endShape.style.text = this._endShape.highlightStyle.text = detail.end;
20945                this._startShape.style.textPosition = this._startShape.highlightStyle.textPosition;
20946                this._endShape.style.textPosition = this._endShape.highlightStyle.textPosition;
20947            }
20948            return true;
20949        },
20950        __ondragend: function () {
20951            if (this.zoomOption.showDetail) {
20952                this._startShape.style.text = this._endShape.style.text = '=';
20953                this._startShape.style.textPosition = this._endShape.style.textPosition = 'inside';
20954                this.zr.modShape(this._startShape.id);
20955                this.zr.modShape(this._endShape.id);
20956                this.zr.refreshNextFrame();
20957            }
20958            this.isDragend = true;
20959        },
20960        ondragend: function (param, status) {
20961            if (!this.isDragend || !param.target) {
20962                return;
20963            }
20964            !this.zoomOption.realtime && this._syncData();
20965            status.dragOut = true;
20966            status.dragIn = true;
20967            if (!this._isSilence && !this.zoomOption.realtime) {
20968                this.messageCenter.dispatch(ecConfig.EVENT.DATA_ZOOM, null, { zoom: this._zoom }, this.myChart);
20969            }
20970            status.needRefresh = false;
20971            this.isDragend = false;
20972            return;
20973        },
20974        ondataZoom: function (param, status) {
20975            status.needRefresh = true;
20976            return;
20977        },
20978        absoluteZoom: function (param) {
20979            this._zoom.start = param.start;
20980            this._zoom.end = param.end;
20981            this._zoom.start2 = param.start2;
20982            this._zoom.end2 = param.end2;
20983            this._syncShape();
20984            this._syncData(true);
20985            return;
20986        },
20987        rectZoom: function (param) {
20988            if (!param) {
20989                this._zoom.start = this._zoom.start2 = 0;
20990                this._zoom.end = this._zoom.end2 = 100;
20991                this._syncShape();
20992                this._syncData(true);
20993                return this._zoom;
20994            }
20995            var gridArea = this.component.grid.getArea();
20996            var rect = {
20997                x: param.x,
20998                y: param.y,
20999                width: param.width,
21000                height: param.height
21001            };
21002            if (rect.width < 0) {
21003                rect.x += rect.width;
21004                rect.width = -rect.width;
21005            }
21006            if (rect.height < 0) {
21007                rect.y += rect.height;
21008                rect.height = -rect.height;
21009            }
21010            if (rect.x > gridArea.x + gridArea.width || rect.y > gridArea.y + gridArea.height) {
21011                return false;
21012            }
21013            if (rect.x < gridArea.x) {
21014                rect.x = gridArea.x;
21015            }
21016            if (rect.x + rect.width > gridArea.x + gridArea.width) {
21017                rect.width = gridArea.x + gridArea.width - rect.x;
21018            }
21019            if (rect.y + rect.height > gridArea.y + gridArea.height) {
21020                rect.height = gridArea.y + gridArea.height - rect.y;
21021            }
21022            var total;
21023            var sdx = (rect.x - gridArea.x) / gridArea.width;
21024            var edx = 1 - (rect.x + rect.width - gridArea.x) / gridArea.width;
21025            var sdy = 1 - (rect.y + rect.height - gridArea.y) / gridArea.height;
21026            var edy = (rect.y - gridArea.y) / gridArea.height;
21027            if (this.zoomOption.orient == 'horizontal') {
21028                total = this._zoom.end - this._zoom.start;
21029                this._zoom.start += total * sdx;
21030                this._zoom.end -= total * edx;
21031                total = this._zoom.end2 - this._zoom.start2;
21032                this._zoom.start2 += total * sdy;
21033                this._zoom.end2 -= total * edy;
21034            } else {
21035                total = this._zoom.end - this._zoom.start;
21036                this._zoom.start += total * sdy;
21037                this._zoom.end -= total * edy;
21038                total = this._zoom.end2 - this._zoom.start2;
21039                this._zoom.start2 += total * sdx;
21040                this._zoom.end2 -= total * edx;
21041            }
21042            this._syncShape();
21043            this._syncData(true);
21044            return this._zoom;
21045        },
21046        syncBackupData: function (curOption) {
21047            var start;
21048            var target = this._originalData['series'];
21049            var curSeries = curOption.series;
21050            var curData;
21051            for (var i = 0, l = curSeries.length; i < l; i++) {
21052                curData = curSeries[i].data || curSeries[i].eventList;
21053                if (target[i]) {
21054                    start = Math.floor(this._zoom.start / 100 * target[i].length);
21055                } else {
21056                    start = 0;
21057                }
21058                for (var j = 0, k = curData.length; j < k; j++) {
21059                    if (target[i]) {
21060                        target[i][j + start] = curData[j];
21061                    }
21062                }
21063            }
21064        },
21065        syncOption: function (magicOption) {
21066            this.silence(true);
21067            this.option = magicOption;
21068            this.option.dataZoom = this.reformOption(this.option.dataZoom);
21069            this.zoomOption = this.option.dataZoom;
21070            if (!this.myChart.canvasSupported) {
21071                this.zoomOption.realtime = false;
21072            }
21073            this.clear();
21074            this._location = this._getLocation();
21075            this._zoom = this._getZoom();
21076            this._backupData();
21077            if (this.option.dataZoom && this.option.dataZoom.show) {
21078                this._buildShape();
21079            }
21080            this._syncData();
21081            this.silence(false);
21082        },
21083        silence: function (s) {
21084            this._isSilence = s;
21085        },
21086        getRealDataIndex: function (sIdx, dIdx) {
21087            if (!this._originalData || this._zoom.start === 0 && this._zoom.end == 100) {
21088                return dIdx;
21089            }
21090            var sreies = this._originalData.series;
21091            if (sreies[sIdx]) {
21092                return Math.floor(this._zoom.start / 100 * sreies[sIdx].length) + dIdx;
21093            }
21094            return -1;
21095        },
21096        resize: function () {
21097            this.clear();
21098            this._location = this._getLocation();
21099            this._zoom = this._getZoom();
21100            if (this.option.dataZoom.show) {
21101                this._buildShape();
21102            }
21103        }
21104    };
21105    zrUtil.inherits(DataZoom, Base);
21106    require('../component').define('dataZoom', DataZoom);
21107    return DataZoom;
21108});define('echarts/component/categoryAxis', [
21109    'require',
21110    './base',
21111    'zrender/shape/Text',
21112    'zrender/shape/Line',
21113    'zrender/shape/Rectangle',
21114    '../config',
21115    'zrender/tool/util',
21116    'zrender/tool/area',
21117    '../component'
21118], function (require) {
21119    var Base = require('./base');
21120    var TextShape = require('zrender/shape/Text');
21121    var LineShape = require('zrender/shape/Line');
21122    var RectangleShape = require('zrender/shape/Rectangle');
21123    var ecConfig = require('../config');
21124    ecConfig.categoryAxis = {
21125        zlevel: 0,
21126        z: 0,
21127        show: true,
21128        position: 'bottom',
21129        name: '',
21130        nameLocation: 'end',
21131        nameTextStyle: {},
21132        boundaryGap: true,
21133        axisLine: {
21134            show: true,
21135            onZero: true,
21136            lineStyle: {
21137                color: '#48b',
21138                width: 2,
21139                type: 'solid'
21140            }
21141        },
21142        axisTick: {
21143            show: true,
21144            interval: 'auto',
21145            inside: false,
21146            length: 5,
21147            lineStyle: {
21148                color: '#333',
21149                width: 1
21150            }
21151        },
21152        axisLabel: {
21153            show: true,
21154            interval: 'auto',
21155            rotate: 0,
21156            margin: 8,
21157            textStyle: { color: '#333' }
21158        },
21159        splitLine: {
21160            show: true,
21161            lineStyle: {
21162                color: ['#ccc'],
21163                width: 1,
21164                type: 'solid'
21165            }
21166        },
21167        splitArea: {
21168            show: false,
21169            areaStyle: {
21170                color: [
21171                    'rgba(250,250,250,0.3)',
21172                    'rgba(200,200,200,0.3)'
21173                ]
21174            }
21175        }
21176    };
21177    var zrUtil = require('zrender/tool/util');
21178    var zrArea = require('zrender/tool/area');
21179    function CategoryAxis(ecTheme, messageCenter, zr, option, myChart, axisBase) {
21180        if (option.data.length < 1) {
21181            console.error('option.data.length < 1.');
21182            return;
21183        }
21184        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
21185        this.grid = this.component.grid;
21186        for (var method in axisBase) {
21187            this[method] = axisBase[method];
21188        }
21189        this.refresh(option);
21190    }
21191    CategoryAxis.prototype = {
21192        type: ecConfig.COMPONENT_TYPE_AXIS_CATEGORY,
21193        _getReformedLabel: function (idx) {
21194            var data = this.getDataFromOption(this.option.data[idx]);
21195            var formatter = this.option.data[idx].formatter || this.option.axisLabel.formatter;
21196            if (formatter) {
21197                if (typeof formatter == 'function') {
21198                    data = formatter.call(this.myChart, data);
21199                } else if (typeof formatter == 'string') {
21200                    data = formatter.replace('{value}', data);
21201                }
21202            }
21203            return data;
21204        },
21205        _getInterval: function () {
21206            var interval = this.option.axisLabel.interval;
21207            if (interval == 'auto') {
21208                var fontSize = this.option.axisLabel.textStyle.fontSize;
21209                var data = this.option.data;
21210                var dataLength = this.option.data.length;
21211                if (this.isHorizontal()) {
21212                    if (dataLength > 3) {
21213                        var gap = this.getGap();
21214                        var isEnough = false;
21215                        var labelSpace;
21216                        var labelSize;
21217                        var step = Math.floor(0.5 / gap);
21218                        step = step < 1 ? 1 : step;
21219                        interval = Math.floor(15 / gap);
21220                        while (!isEnough && interval < dataLength) {
21221                            interval += step;
21222                            isEnough = true;
21223                            labelSpace = Math.floor(gap * interval);
21224                            for (var i = Math.floor((dataLength - 1) / interval) * interval; i >= 0; i -= interval) {
21225                                if (this.option.axisLabel.rotate !== 0) {
21226                                    labelSize = fontSize;
21227                                } else if (data[i].textStyle) {
21228                                    labelSize = zrArea.getTextWidth(this._getReformedLabel(i), this.getFont(zrUtil.merge(data[i].textStyle, this.option.axisLabel.textStyle)));
21229                                } else {
21230                                    var label = this._getReformedLabel(i) + '';
21231                                    var wLen = (label.match(/\w/g) || '').length;
21232                                    var oLen = label.length - wLen;
21233                                    labelSize = wLen * fontSize * 2 / 3 + oLen * fontSize;
21234                                }
21235                                if (labelSpace < labelSize) {
21236                                    isEnough = false;
21237                                    break;
21238                                }
21239                            }
21240                        }
21241                    } else {
21242                        interval = 1;
21243                    }
21244                } else {
21245                    if (dataLength > 3) {
21246                        var gap = this.getGap();
21247                        interval = Math.floor(11 / gap);
21248                        while (gap * interval - 6 < fontSize && interval < dataLength) {
21249                            interval++;
21250                        }
21251                    } else {
21252                        interval = 1;
21253                    }
21254                }
21255            } else {
21256                interval = typeof interval == 'function' ? 1 : interval - 0 + 1;
21257            }
21258            return interval;
21259        },
21260        _buildShape: function () {
21261            this._interval = this._getInterval();
21262            if (!this.option.show) {
21263                return;
21264            }
21265            this.option.splitArea.show && this._buildSplitArea();
21266            this.option.splitLine.show && this._buildSplitLine();
21267            this.option.axisLine.show && this._buildAxisLine();
21268            this.option.axisTick.show && this._buildAxisTick();
21269            this.option.axisLabel.show && this._buildAxisLabel();
21270            for (var i = 0, l = this.shapeList.length; i < l; i++) {
21271                this.zr.addShape(this.shapeList[i]);
21272            }
21273        },
21274        _buildAxisTick: function () {
21275            var axShape;
21276            var data = this.option.data;
21277            var dataLength = this.option.data.length;
21278            var tickOption = this.option.axisTick;
21279            var length = tickOption.length;
21280            var color = tickOption.lineStyle.color;
21281            var lineWidth = tickOption.lineStyle.width;
21282            var intervalFunction = typeof tickOption.interval == 'function' ? tickOption.interval : tickOption.interval == 'auto' ? typeof this.option.axisLabel.interval == 'function' ? this.option.axisLabel.interval : false : false;
21283            var interval = intervalFunction ? 1 : tickOption.interval == 'auto' ? this._interval : tickOption.interval - 0 + 1;
21284            var onGap = tickOption.onGap;
21285            var optGap = onGap ? this.getGap() / 2 : typeof onGap == 'undefined' ? this.option.boundaryGap ? this.getGap() / 2 : 0 : 0;
21286            var startIndex = optGap > 0 ? -interval : 0;
21287            if (this.isHorizontal()) {
21288                var yPosition = this.option.position == 'bottom' ? tickOption.inside ? this.grid.getYend() - length - 1 : this.grid.getYend() + 1 : tickOption.inside ? this.grid.getY() + 1 : this.grid.getY() - length - 1;
21289                var x;
21290                for (var i = startIndex; i < dataLength; i += interval) {
21291                    if (intervalFunction && !intervalFunction(i, data[i])) {
21292                        continue;
21293                    }
21294                    x = this.subPixelOptimize(this.getCoordByIndex(i) + (i >= 0 ? optGap : 0), lineWidth);
21295                    axShape = {
21296                        _axisShape: 'axisTick',
21297                        zlevel: this.getZlevelBase(),
21298                        z: this.getZBase(),
21299                        hoverable: false,
21300                        style: {
21301                            xStart: x,
21302                            yStart: yPosition,
21303                            xEnd: x,
21304                            yEnd: yPosition + length,
21305                            strokeColor: color,
21306                            lineWidth: lineWidth
21307                        }
21308                    };
21309                    this.shapeList.push(new LineShape(axShape));
21310                }
21311            } else {
21312                var xPosition = this.option.position == 'left' ? tickOption.inside ? this.grid.getX() + 1 : this.grid.getX() - length - 1 : tickOption.inside ? this.grid.getXend() - length - 1 : this.grid.getXend() + 1;
21313                var y;
21314                for (var i = startIndex; i < dataLength; i += interval) {
21315                    if (intervalFunction && !intervalFunction(i, data[i])) {
21316                        continue;
21317                    }
21318                    y = this.subPixelOptimize(this.getCoordByIndex(i) - (i >= 0 ? optGap : 0), lineWidth);
21319                    axShape = {
21320                        _axisShape: 'axisTick',
21321                        zlevel: this.getZlevelBase(),
21322                        z: this.getZBase(),
21323                        hoverable: false,
21324                        style: {
21325                            xStart: xPosition,
21326                            yStart: y,
21327                            xEnd: xPosition + length,
21328                            yEnd: y,
21329                            strokeColor: color,
21330                            lineWidth: lineWidth
21331                        }
21332                    };
21333                    this.shapeList.push(new LineShape(axShape));
21334                }
21335            }
21336        },
21337        _buildAxisLabel: function () {
21338            var axShape;
21339            var data = this.option.data;
21340            var dataLength = this.option.data.length;
21341            var labelOption = this.option.axisLabel;
21342            var rotate = labelOption.rotate;
21343            var margin = labelOption.margin;
21344            var clickable = labelOption.clickable;
21345            var textStyle = labelOption.textStyle;
21346            var intervalFunction = typeof labelOption.interval == 'function' ? labelOption.interval : false;
21347            var dataTextStyle;
21348            if (this.isHorizontal()) {
21349                var yPosition;
21350                var baseLine;
21351                if (this.option.position == 'bottom') {
21352                    yPosition = this.grid.getYend() + margin;
21353                    baseLine = 'top';
21354                } else {
21355                    yPosition = this.grid.getY() - margin;
21356                    baseLine = 'bottom';
21357                }
21358                for (var i = 0; i < dataLength; i += this._interval) {
21359                    if (intervalFunction && !intervalFunction(i, data[i]) || this._getReformedLabel(i) === '') {
21360                        continue;
21361                    }
21362                    dataTextStyle = zrUtil.merge(data[i].textStyle || {}, textStyle);
21363                    axShape = {
21364                        zlevel: this.getZlevelBase(),
21365                        z: this.getZBase() + 3,
21366                        hoverable: false,
21367                        style: {
21368                            x: this.getCoordByIndex(i),
21369                            y: yPosition,
21370                            color: dataTextStyle.color,
21371                            text: this._getReformedLabel(i),
21372                            textFont: this.getFont(dataTextStyle),
21373                            textAlign: dataTextStyle.align || 'center',
21374                            textBaseline: dataTextStyle.baseline || baseLine
21375                        }
21376                    };
21377                    if (rotate) {
21378                        axShape.style.textAlign = rotate > 0 ? this.option.position == 'bottom' ? 'right' : 'left' : this.option.position == 'bottom' ? 'left' : 'right';
21379                        axShape.rotation = [
21380                            rotate * Math.PI / 180,
21381                            axShape.style.x,
21382                            axShape.style.y
21383                        ];
21384                    }
21385                    this.shapeList.push(new TextShape(this._axisLabelClickable(clickable, axShape)));
21386                }
21387            } else {
21388                var xPosition;
21389                var align;
21390                if (this.option.position == 'left') {
21391                    xPosition = this.grid.getX() - margin;
21392                    align = 'right';
21393                } else {
21394                    xPosition = this.grid.getXend() + margin;
21395                    align = 'left';
21396                }
21397                for (var i = 0; i < dataLength; i += this._interval) {
21398                    if (intervalFunction && !intervalFunction(i, data[i]) || this._getReformedLabel(i) === '') {
21399                        continue;
21400                    }
21401                    dataTextStyle = zrUtil.merge(data[i].textStyle || {}, textStyle);
21402                    axShape = {
21403                        zlevel: this.getZlevelBase(),
21404                        z: this.getZBase() + 3,
21405                        hoverable: false,
21406                        style: {
21407                            x: xPosition,
21408                            y: this.getCoordByIndex(i),
21409                            color: dataTextStyle.color,
21410                            text: this._getReformedLabel(i),
21411                            textFont: this.getFont(dataTextStyle),
21412                            textAlign: dataTextStyle.align || align,
21413                            textBaseline: dataTextStyle.baseline || i === 0 && this.option.name !== '' ? 'bottom' : i == dataLength - 1 && this.option.name !== '' ? 'top' : 'middle'
21414                        }
21415                    };
21416                    if (rotate) {
21417                        axShape.rotation = [
21418                            rotate * Math.PI / 180,
21419                            axShape.style.x,
21420                            axShape.style.y
21421                        ];
21422                    }
21423                    this.shapeList.push(new TextShape(this._axisLabelClickable(clickable, axShape)));
21424                }
21425            }
21426        },
21427        _buildSplitLine: function () {
21428            var axShape;
21429            var data = this.option.data;
21430            var dataLength = this.option.data.length;
21431            var sLineOption = this.option.splitLine;
21432            var lineType = sLineOption.lineStyle.type;
21433            var lineWidth = sLineOption.lineStyle.width;
21434            var color = sLineOption.lineStyle.color;
21435            color = color instanceof Array ? color : [color];
21436            var colorLength = color.length;
21437            var intervalFunction = typeof this.option.axisLabel.interval == 'function' ? this.option.axisLabel.interval : false;
21438            var onGap = sLineOption.onGap;
21439            var optGap = onGap ? this.getGap() / 2 : typeof onGap == 'undefined' ? this.option.boundaryGap ? this.getGap() / 2 : 0 : 0;
21440            dataLength -= onGap || typeof onGap == 'undefined' && this.option.boundaryGap ? 1 : 0;
21441            if (this.isHorizontal()) {
21442                var sy = this.grid.getY();
21443                var ey = this.grid.getYend();
21444                var x;
21445                for (var i = 0; i < dataLength; i += this._interval) {
21446                    if (intervalFunction && !intervalFunction(i, data[i])) {
21447                        continue;
21448                    }
21449                    x = this.subPixelOptimize(this.getCoordByIndex(i) + optGap, lineWidth);
21450                    axShape = {
21451                        zlevel: this.getZlevelBase(),
21452                        z: this.getZBase(),
21453                        hoverable: false,
21454                        style: {
21455                            xStart: x,
21456                            yStart: sy,
21457                            xEnd: x,
21458                            yEnd: ey,
21459                            strokeColor: color[i / this._interval % colorLength],
21460                            lineType: lineType,
21461                            lineWidth: lineWidth
21462                        }
21463                    };
21464                    this.shapeList.push(new LineShape(axShape));
21465                }
21466            } else {
21467                var sx = this.grid.getX();
21468                var ex = this.grid.getXend();
21469                var y;
21470                for (var i = 0; i < dataLength; i += this._interval) {
21471                    if (intervalFunction && !intervalFunction(i, data[i])) {
21472                        continue;
21473                    }
21474                    y = this.subPixelOptimize(this.getCoordByIndex(i) - optGap, lineWidth);
21475                    axShape = {
21476                        zlevel: this.getZlevelBase(),
21477                        z: this.getZBase(),
21478                        hoverable: false,
21479                        style: {
21480                            xStart: sx,
21481                            yStart: y,
21482                            xEnd: ex,
21483                            yEnd: y,
21484                            strokeColor: color[i / this._interval % colorLength],
21485                            lineType: lineType,
21486                            lineWidth: lineWidth
21487                        }
21488                    };
21489                    this.shapeList.push(new LineShape(axShape));
21490                }
21491            }
21492        },
21493        _buildSplitArea: function () {
21494            var axShape;
21495            var data = this.option.data;
21496            var sAreaOption = this.option.splitArea;
21497            var color = sAreaOption.areaStyle.color;
21498            if (!(color instanceof Array)) {
21499                axShape = {
21500                    zlevel: this.getZlevelBase(),
21501                    z: this.getZBase(),
21502                    hoverable: false,
21503                    style: {
21504                        x: this.grid.getX(),
21505                        y: this.grid.getY(),
21506                        width: this.grid.getWidth(),
21507                        height: this.grid.getHeight(),
21508                        color: color
21509                    }
21510                };
21511                this.shapeList.push(new RectangleShape(axShape));
21512            } else {
21513                var colorLength = color.length;
21514                var dataLength = this.option.data.length;
21515                var intervalFunction = typeof this.option.axisLabel.interval == 'function' ? this.option.axisLabel.interval : false;
21516                var onGap = sAreaOption.onGap;
21517                var optGap = onGap ? this.getGap() / 2 : typeof onGap == 'undefined' ? this.option.boundaryGap ? this.getGap() / 2 : 0 : 0;
21518                if (this.isHorizontal()) {
21519                    var y = this.grid.getY();
21520                    var height = this.grid.getHeight();
21521                    var lastX = this.grid.getX();
21522                    var curX;
21523                    for (var i = 0; i <= dataLength; i += this._interval) {
21524                        if (intervalFunction && !intervalFunction(i, data[i]) && i < dataLength) {
21525                            continue;
21526                        }
21527                        curX = i < dataLength ? this.getCoordByIndex(i) + optGap : this.grid.getXend();
21528                        axShape = {
21529                            zlevel: this.getZlevelBase(),
21530                            z: this.getZBase(),
21531                            hoverable: false,
21532                            style: {
21533                                x: lastX,
21534                                y: y,
21535                                width: curX - lastX,
21536                                height: height,
21537                                color: color[i / this._interval % colorLength]
21538                            }
21539                        };
21540                        this.shapeList.push(new RectangleShape(axShape));
21541                        lastX = curX;
21542                    }
21543                } else {
21544                    var x = this.grid.getX();
21545                    var width = this.grid.getWidth();
21546                    var lastYend = this.grid.getYend();
21547                    var curY;
21548                    for (var i = 0; i <= dataLength; i += this._interval) {
21549                        if (intervalFunction && !intervalFunction(i, data[i]) && i < dataLength) {
21550                            continue;
21551                        }
21552                        curY = i < dataLength ? this.getCoordByIndex(i) - optGap : this.grid.getY();
21553                        axShape = {
21554                            zlevel: this.getZlevelBase(),
21555                            z: this.getZBase(),
21556                            hoverable: false,
21557                            style: {
21558                                x: x,
21559                                y: curY,
21560                                width: width,
21561                                height: lastYend - curY,
21562                                color: color[i / this._interval % colorLength]
21563                            }
21564                        };
21565                        this.shapeList.push(new RectangleShape(axShape));
21566                        lastYend = curY;
21567                    }
21568                }
21569            }
21570        },
21571        refresh: function (newOption) {
21572            if (newOption) {
21573                this.option = this.reformOption(newOption);
21574                this.option.axisLabel.textStyle = this.getTextStyle(this.option.axisLabel.textStyle);
21575            }
21576            this.clear();
21577            this._buildShape();
21578        },
21579        getGap: function () {
21580            var dataLength = this.option.data.length;
21581            var total = this.isHorizontal() ? this.grid.getWidth() : this.grid.getHeight();
21582            if (this.option.boundaryGap) {
21583                return total / dataLength;
21584            } else {
21585                return total / (dataLength > 1 ? dataLength - 1 : 1);
21586            }
21587        },
21588        getCoord: function (value) {
21589            var data = this.option.data;
21590            var dataLength = data.length;
21591            var gap = this.getGap();
21592            var position = this.option.boundaryGap ? gap / 2 : 0;
21593            for (var i = 0; i < dataLength; i++) {
21594                if (this.getDataFromOption(data[i]) == value) {
21595                    if (this.isHorizontal()) {
21596                        position = this.grid.getX() + position;
21597                    } else {
21598                        position = this.grid.getYend() - position;
21599                    }
21600                    return position;
21601                }
21602                position += gap;
21603            }
21604        },
21605        getCoordByIndex: function (dataIndex) {
21606            if (dataIndex < 0) {
21607                if (this.isHorizontal()) {
21608                    return this.grid.getX();
21609                } else {
21610                    return this.grid.getYend();
21611                }
21612            } else if (dataIndex > this.option.data.length - 1) {
21613                if (this.isHorizontal()) {
21614                    return this.grid.getXend();
21615                } else {
21616                    return this.grid.getY();
21617                }
21618            } else {
21619                var gap = this.getGap();
21620                var position = this.option.boundaryGap ? gap / 2 : 0;
21621                position += dataIndex * gap;
21622                if (this.isHorizontal()) {
21623                    position = this.grid.getX() + position;
21624                } else {
21625                    position = this.grid.getYend() - position;
21626                }
21627                return position;
21628            }
21629        },
21630        getNameByIndex: function (dataIndex) {
21631            return this.getDataFromOption(this.option.data[dataIndex]);
21632        },
21633        getIndexByName: function (name) {
21634            var data = this.option.data;
21635            var dataLength = data.length;
21636            for (var i = 0; i < dataLength; i++) {
21637                if (this.getDataFromOption(data[i]) == name) {
21638                    return i;
21639                }
21640            }
21641            return -1;
21642        },
21643        getValueFromCoord: function () {
21644            return '';
21645        },
21646        isMainAxis: function (dataIndex) {
21647            return dataIndex % this._interval === 0;
21648        }
21649    };
21650    zrUtil.inherits(CategoryAxis, Base);
21651    require('../component').define('categoryAxis', CategoryAxis);
21652    return CategoryAxis;
21653});define('echarts/component/valueAxis', [
21654    'require',
21655    './base',
21656    'zrender/shape/Text',
21657    'zrender/shape/Line',
21658    'zrender/shape/Rectangle',
21659    '../config',
21660    '../util/date',
21661    'zrender/tool/util',
21662    '../util/smartSteps',
21663    '../util/accMath',
21664    '../util/smartLogSteps',
21665    '../component'
21666], function (require) {
21667    var Base = require('./base');
21668    var TextShape = require('zrender/shape/Text');
21669    var LineShape = require('zrender/shape/Line');
21670    var RectangleShape = require('zrender/shape/Rectangle');
21671    var ecConfig = require('../config');
21672    ecConfig.valueAxis = {
21673        zlevel: 0,
21674        z: 0,
21675        show: true,
21676        position: 'left',
21677        name: '',
21678        nameLocation: 'end',
21679        nameTextStyle: {},
21680        boundaryGap: [
21681            0,
21682            0
21683        ],
21684        axisLine: {
21685            show: true,
21686            onZero: true,
21687            lineStyle: {
21688                color: '#48b',
21689                width: 2,
21690                type: 'solid'
21691            }
21692        },
21693        axisTick: {
21694            show: false,
21695            inside: false,
21696            length: 5,
21697            lineStyle: {
21698                color: '#333',
21699                width: 1
21700            }
21701        },
21702        axisLabel: {
21703            show: true,
21704            rotate: 0,
21705            margin: 8,
21706            textStyle: { color: '#333' }
21707        },
21708        splitLine: {
21709            show: true,
21710            lineStyle: {
21711                color: ['#ccc'],
21712                width: 1,
21713                type: 'solid'
21714            }
21715        },
21716        splitArea: {
21717            show: false,
21718            areaStyle: {
21719                color: [
21720                    'rgba(250,250,250,0.3)',
21721                    'rgba(200,200,200,0.3)'
21722                ]
21723            }
21724        }
21725    };
21726    var ecDate = require('../util/date');
21727    var zrUtil = require('zrender/tool/util');
21728    function ValueAxis(ecTheme, messageCenter, zr, option, myChart, axisBase, series) {
21729        if (!series || series.length === 0) {
21730            console.err('option.series.length == 0.');
21731            return;
21732        }
21733        Base.call(this, ecTheme, messageCenter, zr, option, myChart);
21734        this.series = series;
21735        this.grid = this.component.grid;
21736        for (var method in axisBase) {
21737            this[method] = axisBase[method];
21738        }
21739        this.refresh(option, series);
21740    }
21741    ValueAxis.prototype = {
21742        type: ecConfig.COMPONENT_TYPE_AXIS_VALUE,
21743        _buildShape: function () {
21744            this._hasData = false;
21745            this._calculateValue();
21746            if (!this._hasData || !this.option.show) {
21747                return;
21748            }
21749            this.option.splitArea.show && this._buildSplitArea();
21750            this.option.splitLine.show && this._buildSplitLine();
21751            this.option.axisLine.show && this._buildAxisLine();
21752            this.option.axisTick.show && this._buildAxisTick();
21753            this.option.axisLabel.show && this._buildAxisLabel();
21754            for (var i = 0, l = this.shapeList.length; i < l; i++) {
21755                this.zr.addShape(this.shapeList[i]);
21756            }
21757        },
21758        _buildAxisTick: function () {
21759            var axShape;
21760            var data = this._valueList;
21761            var dataLength = this._valueList.length;
21762            var tickOption = this.option.axisTick;
21763            var length = tickOption.length;
21764            var color = tickOption.lineStyle.color;
21765            var lineWidth = tickOption.lineStyle.width;
21766            if (this.isHorizontal()) {
21767                var yPosition = this.option.position === 'bottom' ? tickOption.inside ? this.grid.getYend() - length - 1 : this.grid.getYend() + 1 : tickOption.inside ? this.grid.getY() + 1 : this.grid.getY() - length - 1;
21768                var x;
21769                for (var i = 0; i < dataLength; i++) {
21770                    x = this.subPixelOptimize(this.getCoord(data[i]), lineWidth);
21771                    axShape = {
21772                        _axisShape: 'axisTick',
21773                        zlevel: this.getZlevelBase(),
21774                        z: this.getZBase(),
21775                        hoverable: false,
21776                        style: {
21777                            xStart: x,
21778                            yStart: yPosition,
21779                            xEnd: x,
21780                            yEnd: yPosition + length,
21781                            strokeColor: color,
21782                            lineWidth: lineWidth
21783                        }
21784                    };
21785                    this.shapeList.push(new LineShape(axShape));
21786                }
21787            } else {
21788                var xPosition = this.option.position === 'left' ? tickOption.inside ? this.grid.getX() + 1 : this.grid.getX() - length - 1 : tickOption.inside ? this.grid.getXend() - length - 1 : this.grid.getXend() + 1;
21789                var y;
21790                for (var i = 0; i < dataLength; i++) {
21791                    y = this.subPixelOptimize(this.getCoord(data[i]), lineWidth);
21792                    axShape = {
21793                        _axisShape: 'axisTick',
21794                        zlevel: this.getZlevelBase(),
21795                        z: this.getZBase(),
21796                        hoverable: false,
21797                        style: {
21798                            xStart: xPosition,
21799                            yStart: y,
21800                            xEnd: xPosition + length,
21801                            yEnd: y,
21802                            strokeColor: color,
21803                            lineWidth: lineWidth
21804                        }
21805                    };
21806                    this.shapeList.push(new LineShape(axShape));
21807                }
21808            }
21809        },
21810        _buildAxisLabel: function () {
21811            var axShape;
21812            var data = this._valueList;
21813            var dataLength = this._valueList.length;
21814            var rotate = this.option.axisLabel.rotate;
21815            var margin = this.option.axisLabel.margin;
21816            var clickable = this.option.axisLabel.clickable;
21817            var textStyle = this.option.axisLabel.textStyle;
21818            if (this.isHorizontal()) {
21819                var yPosition;
21820                var baseLine;
21821                if (this.option.position === 'bottom') {
21822                    yPosition = this.grid.getYend() + margin;
21823                    baseLine = 'top';
21824                } else {
21825                    yPosition = this.grid.getY() - margin;
21826                    baseLine = 'bottom';
21827                }
21828                for (var i = 0; i < dataLength; i++) {
21829                    axShape = {
21830                        zlevel: this.getZlevelBase(),
21831                        z: this.getZBase() + 3,
21832                        hoverable: false,
21833                        style: {
21834                            x: this.getCoord(data[i]),
21835                            y: yPosition,
21836                            color: typeof textStyle.color === 'function' ? textStyle.color(data[i]) : textStyle.color,
21837                            text: this._valueLabel[i],
21838                            textFont: this.getFont(textStyle),
21839                            textAlign: textStyle.align || 'center',
21840                            textBaseline: textStyle.baseline || baseLine
21841                        }
21842                    };
21843                    if (rotate) {
21844                        axShape.style.textAlign = rotate > 0 ? this.option.position === 'bottom' ? 'right' : 'left' : this.option.position === 'bottom' ? 'left' : 'right';
21845                        axShape.rotation = [
21846                            rotate * Math.PI / 180,
21847                            axShape.style.x,
21848                            axShape.style.y
21849                        ];
21850                    }
21851                    this.shapeList.push(new TextShape(this._axisLabelClickable(clickable, axShape)));
21852                }
21853            } else {
21854                var xPosition;
21855                var align;
21856                if (this.option.position === 'left') {
21857                    xPosition = this.grid.getX() - margin;
21858                    align = 'right';
21859                } else {
21860                    xPosition = this.grid.getXend() + margin;
21861                    align = 'left';
21862                }
21863                for (var i = 0; i < dataLength; i++) {
21864                    axShape = {
21865                        zlevel: this.getZlevelBase(),
21866                        z: this.getZBase() + 3,
21867                        hoverable: false,
21868                        style: {
21869                            x: xPosition,
21870                            y: this.getCoord(data[i]),
21871                            color: typeof textStyle.color === 'function' ? textStyle.color(data[i]) : textStyle.color,
21872                            text: this._valueLabel[i],
21873                            textFont: this.getFont(textStyle),
21874                            textAlign: textStyle.align || align,
21875                            textBaseline: textStyle.baseline || (i === 0 && this.option.name !== '' ? 'bottom' : i === dataLength - 1 && this.option.name !== '' ? 'top' : 'middle')
21876                        }
21877                    };
21878                    if (rotate) {
21879                        axShape.rotation = [
21880                            rotate * Math.PI / 180,
21881                            axShape.style.x,
21882                            axShape.style.y
21883                        ];
21884                    }
21885                    this.shapeList.push(new TextShape(this._axisLabelClickable(clickable, axShape)));
21886                }
21887            }
21888        },
21889        _buildSplitLine: function () {
21890            var axShape;
21891            var data = this._valueList;
21892            var dataLength = this._valueList.length;
21893            var sLineOption = this.option.splitLine;
21894            var lineType = sLineOption.lineStyle.type;
21895            var lineWidth = sLineOption.lineStyle.width;
21896            var color = sLineOption.lineStyle.color;
21897            color = color instanceof Array ? color : [color];
21898            var colorLength = color.length;
21899            if (this.isHorizontal()) {
21900                var sy = this.grid.getY();
21901                var ey = this.grid.getYend();
21902                var x;
21903                for (var i = 0; i < dataLength; i++) {
21904                    x = this.subPixelOptimize(this.getCoord(data[i]), lineWidth);
21905                    axShape = {
21906                        zlevel: this.getZlevelBase(),
21907                        z: this.getZBase(),
21908                        hoverable: false,
21909                        style: {
21910                            xStart: x,
21911                            yStart: sy,
21912                            xEnd: x,
21913                            yEnd: ey,
21914                            strokeColor: color[i % colorLength],
21915                            lineType: lineType,
21916                            lineWidth: lineWidth
21917                        }
21918                    };
21919                    this.shapeList.push(new LineShape(axShape));
21920                }
21921            } else {
21922                var sx = this.grid.getX();
21923                var ex = this.grid.getXend();
21924                var y;
21925                for (var i = 0; i < dataLength; i++) {
21926                    y = this.subPixelOptimize(this.getCoord(data[i]), lineWidth);
21927                    axShape = {
21928                        zlevel: this.getZlevelBase(),
21929                        z: this.getZBase(),
21930                        hoverable: false,
21931                        style: {
21932                            xStart: sx,
21933                            yStart: y,
21934                            xEnd: ex,
21935                            yEnd: y,
21936                            strokeColor: color[i % colorLength],
21937                            lineType: lineType,
21938                            lineWidth: lineWidth
21939                        }
21940                    };
21941                    this.shapeList.push(new LineShape(axShape));
21942                }
21943            }
21944        },
21945        _buildSplitArea: function () {
21946            var axShape;
21947            var color = this.option.splitArea.areaStyle.color;
21948            if (!(color instanceof Array)) {
21949                axShape = {
21950                    zlevel: this.getZlevelBase(),
21951                    z: this.getZBase(),
21952                    hoverable: false,
21953                    style: {
21954                        x: this.grid.getX(),
21955                        y: this.grid.getY(),
21956                        width: this.grid.getWidth(),
21957                        height: this.grid.getHeight(),
21958                        color: color
21959                    }
21960                };
21961                this.shapeList.push(new RectangleShape(axShape));
21962            } else {
21963                var colorLength = color.length;
21964                var data = this._valueList;
21965                var dataLength = this._valueList.length;
21966                if (this.isHorizontal()) {
21967                    var y = this.grid.getY();
21968                    var height = this.grid.getHeight();
21969                    var lastX = this.grid.getX();
21970                    var curX;
21971                    for (var i = 0; i <= dataLength; i++) {
21972                        curX = i < dataLength ? this.getCoord(data[i]) : this.grid.getXend();
21973                        axShape = {
21974                            zlevel: this.getZlevelBase(),
21975                            z: this.getZBase(),
21976                            hoverable: false,
21977                            style: {
21978                                x: lastX,
21979                                y: y,
21980                                width: curX - lastX,
21981                                height: height,
21982                                color: color[i % colorLength]
21983                            }
21984                        };
21985                        this.shapeList.push(new RectangleShape(axShape));
21986                        lastX = curX;
21987                    }
21988                } else {
21989                    var x = this.grid.getX();
21990                    var width = this.grid.getWidth();
21991                    var lastYend = this.grid.getYend();
21992                    var curY;
21993                    for (var i = 0; i <= dataLength; i++) {
21994                        curY = i < dataLength ? this.getCoord(data[i]) : this.grid.getY();
21995                        axShape = {
21996                            zlevel: this.getZlevelBase(),
21997                            z: this.getZBase(),
21998                            hoverable: false,
21999                            style: {
22000                                x: x,
22001                                y: curY,
22002                                width: width,
22003                                height: lastYend - curY,
22004                                color: color[i % colorLength]
22005                            }
22006                        };
22007                        this.shapeList.push(new RectangleShape(axShape));
22008                        lastYend = curY;
22009                    }
22010                }
22011            }
22012        },
22013        _calculateValue: function () {
22014            if (isNaN(this.option.min - 0) || isNaN(this.option.max - 0)) {
22015                var data = {};
22016                var xIdx;
22017                var yIdx;
22018                var legend = this.component.legend;
22019                for (var i = 0, l = this.series.length; i < l; i++) {
22020                    if (this.series[i].type != ecConfig.CHART_TYPE_LINE && this.series[i].type != ecConfig.CHART_TYPE_BAR && this.series[i].type != ecConfig.CHART_TYPE_SCATTER && this.series[i].type != ecConfig.CHART_TYPE_K && this.series[i].type != ecConfig.CHART_TYPE_EVENTRIVER) {
22021                        continue;
22022                    }
22023                    if (legend && !legend.isSelected(this.series[i].name)) {
22024                        continue;
22025                    }
22026                    xIdx = this.series[i].xAxisIndex || 0;
22027                    yIdx = this.series[i].yAxisIndex || 0;
22028                    if (this.option.xAxisIndex != xIdx && this.option.yAxisIndex != yIdx) {
22029                        continue;
22030                    }
22031                    this._calculSum(data, i);
22032                }
22033                var oriData;
22034                for (var i in data) {
22035                    oriData = data[i];
22036                    for (var j = 0, k = oriData.length; j < k; j++) {
22037                        if (!isNaN(oriData[j])) {
22038                            this._hasData = true;
22039                            this._min = oriData[j];
22040                            this._max = oriData[j];
22041                            break;
22042                        }
22043                    }
22044                    if (this._hasData) {
22045                        break;
22046                    }
22047                }
22048                for (var i in data) {
22049                    oriData = data[i];
22050                    for (var j = 0, k = oriData.length; j < k; j++) {
22051                        if (!isNaN(oriData[j])) {
22052                            this._min = Math.min(this._min, oriData[j]);
22053                            this._max = Math.max(this._max, oriData[j]);
22054                        }
22055                    }
22056                }
22057                var boundaryGap = this.option.type !== 'log' ? this.option.boundaryGap : [
22058                    0,
22059                    0
22060                ];
22061                var gap = Math.abs(this._max - this._min);
22062                this._min = isNaN(this.option.min - 0) ? this._min - Math.abs(gap * boundaryGap[0]) : this.option.min - 0;
22063                this._max = isNaN(this.option.max - 0) ? this._max + Math.abs(gap * boundaryGap[1]) : this.option.max - 0;
22064                if (this._min === this._max) {
22065                    if (this._max === 0) {
22066                        this._max = 1;
22067                    } else if (this._max > 0) {
22068                        this._min = this._max / this.option.splitNumber != null ? this.option.splitNumber : 5;
22069                    } else {
22070                        this._max = this._max / this.option.splitNumber != null ? this.option.splitNumber : 5;
22071                    }
22072                }
22073                if (this.option.type === 'time') {
22074                    this._reformTimeValue();
22075                } else if (this.option.type === 'log') {
22076                    this._reformLogValue();
22077                } else {
22078                    this._reformValue(this.option.scale);
22079                }
22080            } else {
22081                this._hasData = true;
22082                this._min = this.option.min - 0;
22083                this._max = this.option.max - 0;
22084                if (this.option.type === 'time') {
22085                    this._reformTimeValue();
22086                } else if (this.option.type === 'log') {
22087                    this._reformLogValue();
22088                } else {
22089                    this._customerValue();
22090                }
22091            }
22092        },
22093        _calculSum: function (data, i) {
22094            var key = this.series[i].name || 'kener';
22095            var value;
22096            var oriData;
22097            if (!this.series[i].stack) {
22098                data[key] = data[key] || [];
22099                if (this.series[i].type != ecConfig.CHART_TYPE_EVENTRIVER) {
22100                    oriData = this.series[i].data;
22101                    for (var j = 0, k = oriData.length; j < k; j++) {
22102                        value = this.getDataFromOption(oriData[j]);
22103                        if (this.series[i].type === ecConfig.CHART_TYPE_K) {
22104                            data[key].push(value[0]);
22105                            data[key].push(value[1]);
22106                            data[key].push(value[2]);
22107                            data[key].push(value[3]);
22108                        } else if (value instanceof Array) {
22109                            if (this.option.xAxisIndex != -1) {
22110                                data[key].push(this.option.type != 'time' ? value[0] : ecDate.getNewDate(value[0]));
22111                            }
22112                            if (this.option.yAxisIndex != -1) {
22113                                data[key].push(this.option.type != 'time' ? value[1] : ecDate.getNewDate(value[1]));
22114                            }
22115                        } else {
22116                            data[key].push(value);
22117                        }
22118                    }
22119                } else {
22120                    oriData = this.series[i].data;
22121                    for (var j = 0, k = oriData.length; j < k; j++) {
22122                        var evolution = oriData[j].evolution;
22123                        for (var m = 0, n = evolution.length; m < n; m++) {
22124                            data[key].push(ecDate.getNewDate(evolution[m].time));
22125                        }
22126                    }
22127                }
22128            } else {
22129                var keyP = '__Magic_Key_Positive__' + this.series[i].stack;
22130                var keyN = '__Magic_Key_Negative__' + this.series[i].stack;
22131                data[keyP] = data[keyP] || [];
22132                data[keyN] = data[keyN] || [];
22133                data[key] = data[key] || [];
22134                oriData = this.series[i].data;
22135                for (var j = 0, k = oriData.length; j < k; j++) {
22136                    value = this.getDataFromOption(oriData[j]);
22137                    if (value === '-') {
22138                        continue;
22139                    }
22140                    value = value - 0;
22141                    if (value >= 0) {
22142                        if (data[keyP][j] != null) {
22143                            data[keyP][j] += value;
22144                        } else {
22145                            data[keyP][j] = value;
22146                        }
22147                    } else {
22148                        if (data[keyN][j] != null) {
22149                            data[keyN][j] += value;
22150                        } else {
22151                            data[keyN][j] = value;
22152                        }
22153                    }
22154                    if (this.option.scale) {
22155                        data[key].push(value);
22156                    }
22157                }
22158            }
22159        },
22160        _reformValue: function (scale) {
22161            var smartSteps = require('../util/smartSteps');
22162            var splitNumber = this.option.splitNumber;
22163            if (!scale && this._min >= 0 && this._max >= 0) {
22164                this._min = 0;
22165            }
22166            if (!scale && this._min <= 0 && this._max <= 0) {
22167                this._max = 0;
22168            }
22169            var stepOpt = smartSteps(this._min, this._max, splitNumber);
22170            splitNumber = splitNumber != null ? splitNumber : stepOpt.secs;
22171            this._min = stepOpt.min;
22172            this._max = stepOpt.max;
22173            this._valueList = stepOpt.pnts;
22174            this._reformLabelData();
22175        },
22176        _reformTimeValue: function () {
22177            var splitNumber = this.option.splitNumber != null ? this.option.splitNumber : 5;
22178            var curValue = ecDate.getAutoFormatter(this._min, this._max, splitNumber);
22179            var formatter = curValue.formatter;
22180            var gapValue = curValue.gapValue;
22181            this._valueList = [ecDate.getNewDate(this._min)];
22182            var startGap;
22183            switch (formatter) {
22184            case 'week':
22185                startGap = ecDate.nextMonday(this._min);
22186                break;
22187            case 'month':
22188                startGap = ecDate.nextNthOnMonth(this._min, 1);
22189                break;
22190            case 'quarter':
22191                startGap = ecDate.nextNthOnQuarterYear(this._min, 1);
22192                break;
22193            case 'half-year':
22194                startGap = ecDate.nextNthOnHalfYear(this._min, 1);
22195                break;
22196            case 'year':
22197                startGap = ecDate.nextNthOnYear(this._min, 1);
22198                break;
22199            default:
22200                if (gapValue <= 3600000 * 2) {
22201                    startGap = (Math.floor(this._min / gapValue) + 1) * gapValue;
22202                } else {
22203                    startGap = ecDate.getNewDate(this._min - -gapValue);
22204                    startGap.setHours(Math.round(startGap.getHours() / 6) * 6);
22205                    startGap.setMinutes(0);
22206                    startGap.setSeconds(0);
22207                }
22208                break;
22209            }
22210            if (startGap - this._min < gapValue / 2) {
22211                startGap -= -gapValue;
22212            }
22213            curValue = ecDate.getNewDate(startGap);
22214            splitNumber *= 1.5;
22215            while (splitNumber-- >= 0) {
22216                if (formatter == 'month' || formatter == 'quarter' || formatter == 'half-year' || formatter == 'year') {
22217                    curValue.setDate(1);
22218                }
22219                if (this._max - curValue < gapValue / 2) {
22220                    break;
22221                }
22222                this._valueList.push(curValue);
22223                curValue = ecDate.getNewDate(curValue - -gapValue);
22224            }
22225            this._valueList.push(ecDate.getNewDate(this._max));
22226            this._reformLabelData(function (formatterStr) {
22227                return function (value) {
22228                    return ecDate.format(formatterStr, value);
22229                };
22230            }(formatter));
22231        },
22232        _customerValue: function () {
22233            var accMath = require('../util/accMath');
22234            var splitNumber = this.option.splitNumber != null ? this.option.splitNumber : 5;
22235            var splitGap = (this._max - this._min) / splitNumber;
22236            this._valueList = [];
22237            for (var i = 0; i <= splitNumber; i++) {
22238                this._valueList.push(accMath.accAdd(this._min, accMath.accMul(splitGap, i)));
22239            }
22240            this._reformLabelData();
22241        },
22242        _reformLogValue: function () {
22243            var thisOption = this.option;
22244            var result = require('../util/smartLogSteps')({
22245                dataMin: this._min,
22246                dataMax: this._max,
22247                logPositive: thisOption.logPositive,
22248                logLabelBase: thisOption.logLabelBase,
22249                splitNumber: thisOption.splitNumber
22250            });
22251            this._min = result.dataMin;
22252            this._max = result.dataMax;
22253            this._valueList = result.tickList;
22254            this._dataMappingMethods = result.dataMappingMethods;
22255            this._reformLabelData(result.labelFormatter);
22256        },
22257        _reformLabelData: function (innerFormatter) {
22258            this._valueLabel = [];
22259            var formatter = this.option.axisLabel.formatter;
22260            if (formatter) {
22261                for (var i = 0, l = this._valueList.length; i < l; i++) {
22262                    if (typeof formatter === 'function') {
22263                        this._valueLabel.push(innerFormatter ? formatter.call(this.myChart, this._valueList[i], innerFormatter) : formatter.call(this.myChart, this._valueList[i]));
22264                    } else if (typeof formatter === 'string') {
22265                        this._valueLabel.push(innerFormatter ? ecDate.format(formatter, this._valueList[i]) : formatter.replace('{value}', this._valueList[i]));
22266                    }
22267                }
22268            } else {
22269                for (var i = 0, l = this._valueList.length; i < l; i++) {
22270                    this._valueLabel.push(innerFormatter ? innerFormatter(this._valueList[i]) : this.numAddCommas(this._valueList[i]));
22271                }
22272            }
22273        },
22274        getExtremum: function () {
22275            this._calculateValue();
22276            var dataMappingMethods = this._dataMappingMethods;
22277            return {
22278                min: this._min,
22279                max: this._max,
22280                dataMappingMethods: dataMappingMethods ? zrUtil.merge({}, dataMappingMethods) : null
22281            };
22282        },
22283        refresh: function (newOption, newSeries) {
22284            if (newOption) {
22285                this.option = this.reformOption(newOption);
22286                this.option.axisLabel.textStyle = zrUtil.merge(this.option.axisLabel.textStyle || {}, this.ecTheme.textStyle);
22287                this.series = newSeries;
22288            }
22289            if (this.zr) {
22290                this.clear();
22291                this._buildShape();
22292            }
22293        },
22294        getCoord: function (value) {
22295            if (this._dataMappingMethods) {
22296                value = this._dataMappingMethods.value2Coord(value);
22297            }
22298            value = value < this._min ? this._min : value;
22299            value = value > this._max ? this._max : value;
22300            var result;
22301            if (!this.isHorizontal()) {
22302                result = this.grid.getYend() - (value - this._min) / (this._max - this._min) * this.grid.getHeight();
22303            } else {
22304                result = this.grid.getX() + (value - this._min) / (this._max - this._min) * this.grid.getWidth();
22305            }
22306            return result;
22307        },
22308        getCoordSize: function (value) {
22309            if (!this.isHorizontal()) {
22310                return Math.abs(value / (this._max - this._min) * this.grid.getHeight());
22311            } else {
22312                return Math.abs(value / (this._max - this._min) * this.grid.getWidth());
22313            }
22314        },
22315        getValueFromCoord: function (coord) {
22316            var result;
22317            if (!this.isHorizontal()) {
22318                coord = coord < this.grid.getY() ? this.grid.getY() : coord;
22319                coord = coord > this.grid.getYend() ? this.grid.getYend() : coord;
22320                result = this._max - (coord - this.grid.getY()) / this.grid.getHeight() * (this._max - this._min);
22321            } else {
22322                coord = coord < this.grid.getX() ? this.grid.getX() : coord;
22323                coord = coord > this.grid.getXend() ? this.grid.getXend() : coord;
22324                result = this._min + (coord - this.grid.getX()) / this.grid.getWidth() * (this._max - this._min);
22325            }
22326            if (this._dataMappingMethods) {
22327                result = this._dataMappingMethods.coord2Value(result);
22328            }
22329            return result.toFixed(2) - 0;
22330        },
22331        isMaindAxis: function (value) {
22332            for (var i = 0, l = this._valueList.length; i < l; i++) {
22333                if (this._valueList[i] === value) {
22334                    return true;
22335                }
22336            }
22337            return false;
22338        }
22339    };
22340    zrUtil.inherits(ValueAxis, Base);
22341    require('../component').define('valueAxis', ValueAxis);
22342    return ValueAxis;
22343});define('echarts/util/date', [], function () {
22344    var _timeGap = [
22345        {
22346            formatter: 'hh : mm : ss',
22347            value: 1000
22348        },
22349        {
22350            formatter: 'hh : mm : ss',
22351            value: 1000 * 5
22352        },
22353        {
22354            formatter: 'hh : mm : ss',
22355            value: 1000 * 10
22356        },
22357        {
22358            formatter: 'hh : mm : ss',
22359            value: 1000 * 15
22360        },
22361        {
22362            formatter: 'hh : mm : ss',
22363            value: 1000 * 30
22364        },
22365        {
22366            formatter: 'hh : mm\nMM - dd',
22367            value: 60000
22368        },
22369        {
22370            formatter: 'hh : mm\nMM - dd',
22371            value: 60000 * 5
22372        },
22373        {
22374            formatter: 'hh : mm\nMM - dd',
22375            value: 60000 * 10
22376        },
22377        {
22378            formatter: 'hh : mm\nMM - dd',
22379            value: 60000 * 15
22380        },
22381        {
22382            formatter: 'hh : mm\nMM - dd',
22383            value: 60000 * 30
22384        },
22385        {
22386            formatter: 'hh : mm\nMM - dd',
22387            value: 3600000
22388        },
22389        {
22390            formatter: 'hh : mm\nMM - dd',
22391            value: 3600000 * 2
22392        },
22393        {
22394            formatter: 'hh : mm\nMM - dd',
22395            value: 3600000 * 6
22396        },
22397        {
22398            formatter: 'hh : mm\nMM - dd',
22399            value: 3600000 * 12
22400        },
22401        {
22402            formatter: 'MM - dd\nyyyy',
22403            value: 3600000 * 24
22404        },
22405        {
22406            formatter: 'week',
22407            value: 3600000 * 24 * 7
22408        },
22409        {
22410            formatter: 'month',
22411            value: 3600000 * 24 * 31
22412        },
22413        {
22414            formatter: 'quarter',
22415            value: 3600000 * 24 * 380 / 4
22416        },
22417        {
22418            formatter: 'half-year',
22419            value: 3600000 * 24 * 380 / 2
22420        },
22421        {
22422            formatter: 'year',
22423            value: 3600000 * 24 * 380
22424        }
22425    ];
22426    function getAutoFormatter(min, max, splitNumber) {
22427        splitNumber = splitNumber > 1 ? splitNumber : 2;
22428        var curValue;
22429        var totalGap;
22430        var formatter;
22431        var gapValue;
22432        for (var i = 0, l = _timeGap.length; i < l; i++) {
22433            curValue = _timeGap[i].value;
22434            totalGap = Math.ceil(max / curValue) * curValue - Math.floor(min / curValue) * curValue;
22435            if (Math.round(totalGap / curValue) <= splitNumber * 1.2) {
22436                formatter = _timeGap[i].formatter;
22437                gapValue = _timeGap[i].value;
22438                break;
22439            }
22440        }
22441        if (formatter == null) {
22442            formatter = 'year';
22443            curValue = 3600000 * 24 * 367;
22444            totalGap = Math.ceil(max / curValue) * curValue - Math.floor(min / curValue) * curValue;
22445            gapValue = Math.round(totalGap / (splitNumber - 1) / curValue) * curValue;
22446        }
22447        return {
22448            formatter: formatter,
22449            gapValue: gapValue
22450        };
22451    }
22452    function s2d(v) {
22453        return v < 10 ? '0' + v : v;
22454    }
22455    function format(formatter, value) {
22456        if (formatter == 'week' || formatter == 'month' || formatter == 'quarter' || formatter == 'half-year' || formatter == 'year') {
22457            formatter = 'MM - dd\nyyyy';
22458        }
22459        var date = getNewDate(value);
22460        var y = date.getFullYear();
22461        var M = date.getMonth() + 1;
22462        var d = date.getDate();
22463        var h = date.getHours();
22464        var m = date.getMinutes();
22465        var s = date.getSeconds();
22466        formatter = formatter.replace('MM', s2d(M));
22467        formatter = formatter.toLowerCase();
22468        formatter = formatter.replace('yyyy', y);
22469        formatter = formatter.replace('yy', y % 100);
22470        formatter = formatter.replace('dd', s2d(d));
22471        formatter = formatter.replace('d', d);
22472        formatter = formatter.replace('hh', s2d(h));
22473        formatter = formatter.replace('h', h);
22474        formatter = formatter.replace('mm', s2d(m));
22475        formatter = formatter.replace('m', m);
22476        formatter = formatter.replace('ss', s2d(s));
22477        formatter = formatter.replace('s', s);
22478        return formatter;
22479    }
22480    function nextMonday(value) {
22481        value = getNewDate(value);
22482        value.setDate(value.getDate() + 8 - value.getDay());
22483        return value;
22484    }
22485    function nextNthPerNmonth(value, nth, nmon) {
22486        value = getNewDate(value);
22487        value.setMonth(Math.ceil((value.getMonth() + 1) / nmon) * nmon);
22488        value.setDate(nth);
22489        return value;
22490    }
22491    function nextNthOnMonth(value, nth) {
22492        return nextNthPerNmonth(value, nth, 1);
22493    }
22494    function nextNthOnQuarterYear(value, nth) {
22495        return nextNthPerNmonth(value, nth, 3);
22496    }
22497    function nextNthOnHalfYear(value, nth) {
22498        return nextNthPerNmonth(value, nth, 6);
22499    }
22500    function nextNthOnYear(value, nth) {
22501        return nextNthPerNmonth(value, nth, 12);
22502    }
22503    function getNewDate(value) {
22504        return value instanceof Date ? value : new Date(typeof value == 'string' ? value.replace(/-/g, '/') : value);
22505    }
22506    return {
22507        getAutoFormatter: getAutoFormatter,
22508        getNewDate: getNewDate,
22509        format: format,
22510        nextMonday: nextMonday,
22511        nextNthPerNmonth: nextNthPerNmonth,
22512        nextNthOnMonth: nextNthOnMonth,
22513        nextNthOnQuarterYear: nextNthOnQuarterYear,
22514        nextNthOnHalfYear: nextNthOnHalfYear,
22515        nextNthOnYear: nextNthOnYear
22516    };
22517});define('echarts/util/smartSteps', [], function () {
22518    var mySteps = [
22519        10,
22520        20,
22521        25,
22522        50
22523    ];
22524    var mySections = [
22525        4,
22526        5,
22527        6
22528    ];
22529    var custOpts;
22530    var custSteps;
22531    var custSecs;
22532    var minLocked;
22533    var maxLocked;
22534    var MT = Math;
22535    var MATH_ROUND = MT.round;
22536    var MATH_FLOOR = MT.floor;
22537    var MATH_CEIL = MT.ceil;
22538    var MATH_ABS = MT.abs;
22539    function MATH_LOG(n) {
22540        return MT.log(MATH_ABS(n)) / MT.LN10;
22541    }
22542    function MATH_POW(n) {
22543        return MT.pow(10, n);
22544    }
22545    function MATH_ISINT(n) {
22546        return n === MATH_FLOOR(n);
22547    }
22548    function smartSteps(min, max, section, opts) {
22549        custOpts = opts || {};
22550        custSteps = custOpts.steps || mySteps;
22551        custSecs = custOpts.secs || mySections;
22552        section = MATH_ROUND(+section || 0) % 99;
22553        min = +min || 0;
22554        max = +max || 0;
22555        minLocked = maxLocked = 0;
22556        if ('min' in custOpts) {
22557            min = +custOpts.min || 0;
22558            minLocked = 1;
22559        }
22560        if ('max' in custOpts) {
22561            max = +custOpts.max || 0;
22562            maxLocked = 1;
22563        }
22564        if (min > max) {
22565            max = [
22566                min,
22567                min = max
22568            ][0];
22569        }
22570        var span = max - min;
22571        if (minLocked && maxLocked) {
22572            return bothLocked(min, max, section);
22573        }
22574        if (span < (section || 5)) {
22575            if (MATH_ISINT(min) && MATH_ISINT(max)) {
22576                return forInteger(min, max, section);
22577            } else if (span === 0) {
22578                return forSpan0(min, max, section);
22579            }
22580        }
22581        return coreCalc(min, max, section);
22582    }
22583    function makeResult(newMin, newMax, section, expon) {
22584        expon = expon || 0;
22585        var expStep = expNum((newMax - newMin) / section, -1);
22586        var expMin = expNum(newMin, -1, 1);
22587        var expMax = expNum(newMax, -1);
22588        var minExp = MT.min(expStep.e, expMin.e, expMax.e);
22589        if (expMin.c === 0) {
22590            minExp = MT.min(expStep.e, expMax.e);
22591        } else if (expMax.c === 0) {
22592            minExp = MT.min(expStep.e, expMin.e);
22593        }
22594        expFixTo(expStep, {
22595            c: 0,
22596            e: minExp
22597        });
22598        expFixTo(expMin, expStep, 1);
22599        expFixTo(expMax, expStep);
22600        expon += minExp;
22601        newMin = expMin.c;
22602        newMax = expMax.c;
22603        var step = (newMax - newMin) / section;
22604        var zoom = MATH_POW(expon);
22605        var fixTo = 0;
22606        var points = [];
22607        for (var i = section + 1; i--;) {
22608            points[i] = (newMin + step * i) * zoom;
22609        }
22610        if (expon < 0) {
22611            fixTo = decimals(zoom);
22612            step = +(step * zoom).toFixed(fixTo);
22613            newMin = +(newMin * zoom).toFixed(fixTo);
22614            newMax = +(newMax * zoom).toFixed(fixTo);
22615            for (var i = points.length; i--;) {
22616                points[i] = points[i].toFixed(fixTo);
22617                +points[i] === 0 && (points[i] = '0');
22618            }
22619        } else {
22620            newMin *= zoom;
22621            newMax *= zoom;
22622            step *= zoom;
22623        }
22624        custSecs = 0;
22625        custSteps = 0;
22626        custOpts = 0;
22627        return {
22628            min: newMin,
22629            max: newMax,
22630            secs: section,
22631            step: step,
22632            fix: fixTo,
22633            exp: expon,
22634            pnts: points
22635        };
22636    }
22637    function expNum(num, digit, byFloor) {
22638        digit = MATH_ROUND(digit % 10) || 2;
22639        if (digit < 0) {
22640            if (MATH_ISINT(num)) {
22641                digit = ('' + MATH_ABS(num)).replace(/0+$/, '').length || 1;
22642            } else {
22643                num = num.toFixed(15).replace(/0+$/, '');
22644                digit = num.replace('.', '').replace(/^[-0]+/, '').length;
22645                num = +num;
22646            }
22647        }
22648        var expon = MATH_FLOOR(MATH_LOG(num)) - digit + 1;
22649        var cNum = +(num * MATH_POW(-expon)).toFixed(15) || 0;
22650        cNum = byFloor ? MATH_FLOOR(cNum) : MATH_CEIL(cNum);
22651        !cNum && (expon = 0);
22652        if (('' + MATH_ABS(cNum)).length > digit) {
22653            expon += 1;
22654            cNum /= 10;
22655        }
22656        return {
22657            c: cNum,
22658            e: expon
22659        };
22660    }
22661    function expFixTo(expnum1, expnum2, byFloor) {
22662        var deltaExp = expnum2.e - expnum1.e;
22663        if (deltaExp) {
22664            expnum1.e += deltaExp;
22665            expnum1.c *= MATH_POW(-deltaExp);
22666            expnum1.c = byFloor ? MATH_FLOOR(expnum1.c) : MATH_CEIL(expnum1.c);
22667        }
22668    }
22669    function expFixMin(expnum1, expnum2, byFloor) {
22670        if (expnum1.e < expnum2.e) {
22671            expFixTo(expnum2, expnum1, byFloor);
22672        } else {
22673            expFixTo(expnum1, expnum2, byFloor);
22674        }
22675    }
22676    function getCeil(num, rounds) {
22677        rounds = rounds || mySteps;
22678        num = expNum(num);
22679        var cNum = num.c;
22680        var i = 0;
22681        while (cNum > rounds[i]) {
22682            i++;
22683        }
22684        if (!rounds[i]) {
22685            cNum /= 10;
22686            num.e += 1;
22687            i = 0;
22688            while (cNum > rounds[i]) {
22689                i++;
22690            }
22691        }
22692        num.c = rounds[i];
22693        return num;
22694    }
22695    function coreCalc(min, max, section) {
22696        var step;
22697        var secs = section || +custSecs.slice(-1);
22698        var expStep = getCeil((max - min) / secs, custSteps);
22699        var expSpan = expNum(max - min);
22700        var expMin = expNum(min, -1, 1);
22701        var expMax = expNum(max, -1);
22702        expFixTo(expSpan, expStep);
22703        expFixTo(expMin, expStep, 1);
22704        expFixTo(expMax, expStep);
22705        if (!section) {
22706            secs = look4sections(expMin, expMax);
22707        } else {
22708            step = look4step(expMin, expMax, secs);
22709        }
22710        if (MATH_ISINT(min) && MATH_ISINT(max) && min * max >= 0) {
22711            if (max - min < secs) {
22712                return forInteger(min, max, secs);
22713            }
22714            secs = tryForInt(min, max, section, expMin, expMax, secs);
22715        }
22716        var arrMM = cross0(min, max, expMin.c, expMax.c);
22717        expMin.c = arrMM[0];
22718        expMax.c = arrMM[1];
22719        if (minLocked || maxLocked) {
22720            singleLocked(min, max, expMin, expMax);
22721        }
22722        return makeResult(expMin.c, expMax.c, secs, expMax.e);
22723    }
22724    function look4sections(expMin, expMax) {
22725        var section;
22726        var tmpStep, tmpMin, tmpMax;
22727        var reference = [];
22728        for (var i = custSecs.length; i--;) {
22729            section = custSecs[i];
22730            tmpStep = getCeil((expMax.c - expMin.c) / section, custSteps);
22731            tmpStep = tmpStep.c * MATH_POW(tmpStep.e);
22732            tmpMin = MATH_FLOOR(expMin.c / tmpStep) * tmpStep;
22733            tmpMax = MATH_CEIL(expMax.c / tmpStep) * tmpStep;
22734            reference[i] = {
22735                min: tmpMin,
22736                max: tmpMax,
22737                step: tmpStep,
22738                span: tmpMax - tmpMin
22739            };
22740        }
22741        reference.sort(function (a, b) {
22742            var delta = a.span - b.span;
22743            if (delta === 0) {
22744                delta = a.step - b.step;
22745            }
22746            return delta;
22747        });
22748        reference = reference[0];
22749        section = reference.span / reference.step;
22750        expMin.c = reference.min;
22751        expMax.c = reference.max;
22752        return section < 3 ? section * 2 : section;
22753    }
22754    function look4step(expMin, expMax, secs) {
22755        var span;
22756        var tmpMax;
22757        var tmpMin = expMax.c;
22758        var tmpStep = (expMax.c - expMin.c) / secs - 1;
22759        while (tmpMin > expMin.c) {
22760            tmpStep = getCeil(tmpStep + 1, custSteps);
22761            tmpStep = tmpStep.c * MATH_POW(tmpStep.e);
22762            span = tmpStep * secs;
22763            tmpMax = MATH_CEIL(expMax.c / tmpStep) * tmpStep;
22764            tmpMin = tmpMax - span;
22765        }
22766        var deltaMin = expMin.c - tmpMin;
22767        var deltaMax = tmpMax - expMax.c;
22768        var deltaDelta = deltaMin - deltaMax;
22769        if (deltaDelta > tmpStep * 1.1) {
22770            deltaDelta = MATH_ROUND(deltaDelta / tmpStep / 2) * tmpStep;
22771            tmpMin += deltaDelta;
22772            tmpMax += deltaDelta;
22773        }
22774        expMin.c = tmpMin;
22775        expMax.c = tmpMax;
22776        return tmpStep;
22777    }
22778    function tryForInt(min, max, section, expMin, expMax, secs) {
22779        var span = expMax.c - expMin.c;
22780        var step = span / secs * MATH_POW(expMax.e);
22781        if (!MATH_ISINT(step)) {
22782            step = MATH_FLOOR(step);
22783            span = step * secs;
22784            if (span < max - min) {
22785                step += 1;
22786                span = step * secs;
22787                if (!section && step * (secs - 1) >= max - min) {
22788                    secs -= 1;
22789                    span = step * secs;
22790                }
22791            }
22792            if (span >= max - min) {
22793                var delta = span - (max - min);
22794                expMin.c = MATH_ROUND(min - delta / 2);
22795                expMax.c = MATH_ROUND(max + delta / 2);
22796                expMin.e = 0;
22797                expMax.e = 0;
22798            }
22799        }
22800        return secs;
22801    }
22802    function forInteger(min, max, section) {
22803        section = section || 5;
22804        if (minLocked) {
22805            max = min + section;
22806        } else if (maxLocked) {
22807            min = max - section;
22808        } else {
22809            var delta = section - (max - min);
22810            var newMin = MATH_ROUND(min - delta / 2);
22811            var newMax = MATH_ROUND(max + delta / 2);
22812            var arrMM = cross0(min, max, newMin, newMax);
22813            min = arrMM[0];
22814            max = arrMM[1];
22815        }
22816        return makeResult(min, max, section);
22817    }
22818    function forSpan0(min, max, section) {
22819        section = section || 5;
22820        var delta = MT.min(MATH_ABS(max / section), section) / 2.1;
22821        if (minLocked) {
22822            max = min + delta;
22823        } else if (maxLocked) {
22824            min = max - delta;
22825        } else {
22826            min = min - delta;
22827            max = max + delta;
22828        }
22829        return coreCalc(min, max, section);
22830    }
22831    function cross0(min, max, newMin, newMax) {
22832        if (min >= 0 && newMin < 0) {
22833            newMax -= newMin;
22834            newMin = 0;
22835        } else if (max <= 0 && newMax > 0) {
22836            newMin -= newMax;
22837            newMax = 0;
22838        }
22839        return [
22840            newMin,
22841            newMax
22842        ];
22843    }
22844    function decimals(num) {
22845        num = (+num).toFixed(15).split('.');
22846        return num.pop().replace(/0+$/, '').length;
22847    }
22848    function singleLocked(min, max, emin, emax) {
22849        if (minLocked) {
22850            var expMin = expNum(min, 4, 1);
22851            if (emin.e - expMin.e > 6) {
22852                expMin = {
22853                    c: 0,
22854                    e: emin.e
22855                };
22856            }
22857            expFixMin(emin, expMin);
22858            expFixMin(emax, expMin);
22859            emax.c += expMin.c - emin.c;
22860            emin.c = expMin.c;
22861        } else if (maxLocked) {
22862            var expMax = expNum(max, 4);
22863            if (emax.e - expMax.e > 6) {
22864                expMax = {
22865                    c: 0,
22866                    e: emax.e
22867                };
22868            }
22869            expFixMin(emin, expMax);
22870            expFixMin(emax, expMax);
22871            emin.c += expMax.c - emax.c;
22872            emax.c = expMax.c;
22873        }
22874    }
22875    function bothLocked(min, max, section) {
22876        var trySecs = section ? [section] : custSecs;
22877        var span = max - min;
22878        if (span === 0) {
22879            max = expNum(max, 3);
22880            section = trySecs[0];
22881            max.c = MATH_ROUND(max.c + section / 2);
22882            return makeResult(max.c - section, max.c, section, max.e);
22883        }
22884        if (MATH_ABS(max / span) < 0.000001) {
22885            max = 0;
22886        }
22887        if (MATH_ABS(min / span) < 0.000001) {
22888            min = 0;
22889        }
22890        var step, deltaSpan, score;
22891        var scoreS = [
22892            [
22893                5,
22894                10
22895            ],
22896            [
22897                10,
22898                2
22899            ],
22900            [
22901                50,
22902                10
22903            ],
22904            [
22905                100,
22906                2
22907            ]
22908        ];
22909        var reference = [];
22910        var debugLog = [];
22911        var expSpan = expNum(max - min, 3);
22912        var expMin = expNum(min, -1, 1);
22913        var expMax = expNum(max, -1);
22914        expFixTo(expMin, expSpan, 1);
22915        expFixTo(expMax, expSpan);
22916        span = expMax.c - expMin.c;
22917        expSpan.c = span;
22918        for (var i = trySecs.length; i--;) {
22919            section = trySecs[i];
22920            step = MATH_CEIL(span / section);
22921            deltaSpan = step * section - span;
22922            score = (deltaSpan + 3) * 3;
22923            score += (section - trySecs[0] + 2) * 2;
22924            if (section % 5 === 0) {
22925                score -= 10;
22926            }
22927            for (var j = scoreS.length; j--;) {
22928                if (step % scoreS[j][0] === 0) {
22929                    score /= scoreS[j][1];
22930                }
22931            }
22932            debugLog[i] = [
22933                section,
22934                step,
22935                deltaSpan,
22936                score
22937            ].join();
22938            reference[i] = {
22939                secs: section,
22940                step: step,
22941                delta: deltaSpan,
22942                score: score
22943            };
22944        }
22945        reference.sort(function (a, b) {
22946            return a.score - b.score;
22947        });
22948        reference = reference[0];
22949        expMin.c = MATH_ROUND(expMin.c - reference.delta / 2);
22950        expMax.c = MATH_ROUND(expMax.c + reference.delta / 2);
22951        return makeResult(expMin.c, expMax.c, reference.secs, expSpan.e);
22952    }
22953    return smartSteps;
22954});define('echarts/util/smartLogSteps', [
22955    'require',
22956    './number'
22957], function (require) {
22958    var number = require('./number');
22959    var Mt = Math;
22960    var mathLog = Mt.log;
22961    var mathPow = Mt.pow;
22962    var mathAbs = Mt.abs;
22963    var mathCeil = Mt.ceil;
22964    var mathFloor = Mt.floor;
22965    var LOG_BASE = Mt.E;
22966    var LN10 = Mt.LN10;
22967    var LN2 = Mt.LN2;
22968    var LN2D10 = LN2 / LN10;
22969    var EPSILON = 1e-9;
22970    var DEFAULT_SPLIT_NUMBER = 5;
22971    var MIN_BASE_10_SPLIT_NUMBER = 2;
22972    var SUPERSCRIPTS = {
22973        '0': '⁰',
22974        '1': '¹',
22975        '2': '²',
22976        '3': '³',
22977        '4': '⁴',
22978        '5': '⁵',
22979        '6': '⁶',
22980        '7': '⁷',
22981        '8': '⁸',
22982        '9': '⁹',
22983        '-': '⁻'
22984    };
22985    var logPositive;
22986    var logLabelBase;
22987    var logLabelMode;
22988    var lnBase;
22989    var custOpts;
22990    var splitNumber;
22991    var logMappingOffset;
22992    var absMin;
22993    var absMax;
22994    var tickList;
22995    function smartLogSteps(opts) {
22996        clearStaticVariables();
22997        custOpts = opts || {};
22998        reformSetting();
22999        makeTicksList();
23000        return [
23001            makeResult(),
23002            clearStaticVariables()
23003        ][0];
23004    }
23005    function clearStaticVariables() {
23006        logPositive = custOpts = logMappingOffset = lnBase = absMin = absMax = splitNumber = tickList = logLabelBase = logLabelMode = null;
23007    }
23008    function reformSetting() {
23009        logLabelBase = custOpts.logLabelBase;
23010        if (logLabelBase == null) {
23011            logLabelMode = 'plain';
23012            logLabelBase = 10;
23013            lnBase = LN10;
23014        } else {
23015            logLabelBase = +logLabelBase;
23016            if (logLabelBase < 1) {
23017                logLabelBase = 10;
23018            }
23019            logLabelMode = 'exponent';
23020            lnBase = mathLog(logLabelBase);
23021        }
23022        splitNumber = custOpts.splitNumber;
23023        splitNumber == null && (splitNumber = DEFAULT_SPLIT_NUMBER);
23024        var dataMin = parseFloat(custOpts.dataMin);
23025        var dataMax = parseFloat(custOpts.dataMax);
23026        if (!isFinite(dataMin) && !isFinite(dataMax)) {
23027            dataMin = dataMax = 1;
23028        } else if (!isFinite(dataMin)) {
23029            dataMin = dataMax;
23030        } else if (!isFinite(dataMax)) {
23031            dataMax = dataMin;
23032        } else if (dataMin > dataMax) {
23033            dataMax = [
23034                dataMin,
23035                dataMin = dataMax
23036            ][0];
23037        }
23038        logPositive = custOpts.logPositive;
23039        if (logPositive == null) {
23040            logPositive = dataMax > 0 || dataMin === 0;
23041        }
23042        absMin = logPositive ? dataMin : -dataMax;
23043        absMax = logPositive ? dataMax : -dataMin;
23044        absMin < EPSILON && (absMin = EPSILON);
23045        absMax < EPSILON && (absMax = EPSILON);
23046    }
23047    function makeTicksList() {
23048        tickList = [];
23049        var maxDataLog = fixAccurate(mathLog(absMax) / lnBase);
23050        var minDataLog = fixAccurate(mathLog(absMin) / lnBase);
23051        var maxExpon = mathCeil(maxDataLog);
23052        var minExpon = mathFloor(minDataLog);
23053        var spanExpon = maxExpon - minExpon;
23054        var spanDataLog = maxDataLog - minDataLog;
23055        if (logLabelMode === 'exponent') {
23056            baseAnalysis();
23057        } else {
23058            !(spanExpon <= MIN_BASE_10_SPLIT_NUMBER && splitNumber > MIN_BASE_10_SPLIT_NUMBER) ? baseAnalysis() : detailAnalysis();
23059        }
23060        function baseAnalysis() {
23061            if (spanExpon < splitNumber) {
23062                splitNumber = spanExpon;
23063            }
23064            var stepExpon = mathFloor(fixAccurate(spanExpon / splitNumber));
23065            var splitNumberAdjust = mathCeil(fixAccurate(spanExpon / stepExpon));
23066            var spanExponAdjust = stepExpon * splitNumberAdjust;
23067            var halfDiff = (spanExponAdjust - spanDataLog) / 2;
23068            var minExponAdjust = mathFloor(fixAccurate(minDataLog - halfDiff));
23069            if (aroundZero(minExponAdjust - minDataLog)) {
23070                minExponAdjust -= 1;
23071            }
23072            logMappingOffset = -minExponAdjust * lnBase;
23073            for (var n = minExponAdjust; n - stepExpon <= maxDataLog; n += stepExpon) {
23074                tickList.push(mathPow(logLabelBase, n));
23075            }
23076        }
23077        function detailAnalysis() {
23078            var minDecimal = toDecimalFrom4Hex(minExpon, 0);
23079            var endDecimal = minDecimal + 2;
23080            while (minDecimal < endDecimal && toH(minDecimal + 1) + toK(minDecimal + 1) * LN2D10 < minDataLog) {
23081                minDecimal++;
23082            }
23083            var maxDecimal = toDecimalFrom4Hex(maxExpon, 0);
23084            var endDecimal = maxDecimal - 2;
23085            while (maxDecimal > endDecimal && toH(maxDecimal - 1) + toK(maxDecimal - 1) * LN2D10 > maxDataLog) {
23086                maxDecimal--;
23087            }
23088            logMappingOffset = -(toH(minDecimal) * LN10 + toK(minDecimal) * LN2);
23089            for (var i = minDecimal; i <= maxDecimal; i++) {
23090                var h = toH(i);
23091                var k = toK(i);
23092                tickList.push(mathPow(10, h) * mathPow(2, k));
23093            }
23094        }
23095        function toDecimalFrom4Hex(h, k) {
23096            return h * 3 + k;
23097        }
23098        function toK(decimal) {
23099            return decimal - toH(decimal) * 3;
23100        }
23101        function toH(decimal) {
23102            return mathFloor(fixAccurate(decimal / 3));
23103        }
23104    }
23105    function makeResult() {
23106        var resultTickList = [];
23107        for (var i = 0, len = tickList.length; i < len; i++) {
23108            resultTickList[i] = (logPositive ? 1 : -1) * tickList[i];
23109        }
23110        !logPositive && resultTickList.reverse();
23111        var dataMappingMethods = makeDataMappingMethods();
23112        var value2Coord = dataMappingMethods.value2Coord;
23113        var newDataMin = value2Coord(resultTickList[0]);
23114        var newDataMax = value2Coord(resultTickList[resultTickList.length - 1]);
23115        if (newDataMin === newDataMax) {
23116            newDataMin -= 1;
23117            newDataMax += 1;
23118        }
23119        return {
23120            dataMin: newDataMin,
23121            dataMax: newDataMax,
23122            tickList: resultTickList,
23123            logPositive: logPositive,
23124            labelFormatter: makeLabelFormatter(),
23125            dataMappingMethods: dataMappingMethods
23126        };
23127    }
23128    function makeLabelFormatter() {
23129        if (logLabelMode === 'exponent') {
23130            var myLogLabelBase = logLabelBase;
23131            var myLnBase = lnBase;
23132            return function (value) {
23133                if (!isFinite(parseFloat(value))) {
23134                    return '';
23135                }
23136                var sign = '';
23137                if (value < 0) {
23138                    value = -value;
23139                    sign = '-';
23140                }
23141                return sign + myLogLabelBase + makeSuperscriptExponent(mathLog(value) / myLnBase);
23142            };
23143        } else {
23144            return function (value) {
23145                if (!isFinite(parseFloat(value))) {
23146                    return '';
23147                }
23148                return number.addCommas(formatNumber(value));
23149            };
23150        }
23151    }
23152    function makeDataMappingMethods() {
23153        var myLogPositive = logPositive;
23154        var myLogMappingOffset = logMappingOffset;
23155        return {
23156            value2Coord: function (x) {
23157                if (x == null || isNaN(x) || !isFinite(x)) {
23158                    return x;
23159                }
23160                x = parseFloat(x);
23161                if (!isFinite(x)) {
23162                    x = EPSILON;
23163                } else if (myLogPositive && x < EPSILON) {
23164                    x = EPSILON;
23165                } else if (!myLogPositive && x > -EPSILON) {
23166                    x = -EPSILON;
23167                }
23168                x = mathAbs(x);
23169                return (myLogPositive ? 1 : -1) * (mathLog(x) + myLogMappingOffset);
23170            },
23171            coord2Value: function (x) {
23172                if (x == null || isNaN(x) || !isFinite(x)) {
23173                    return x;
23174                }
23175                x = parseFloat(x);
23176                if (!isFinite(x)) {
23177                    x = EPSILON;
23178                }
23179                return myLogPositive ? mathPow(LOG_BASE, x - myLogMappingOffset) : -mathPow(LOG_BASE, -x + myLogMappingOffset);
23180            }
23181        };
23182    }
23183    function fixAccurate(result) {
23184        return +Number(+result).toFixed(14);
23185    }
23186    function formatNumber(num) {
23187        return Number(num).toFixed(15).replace(/\.?0*$/, '');
23188    }
23189    function makeSuperscriptExponent(exponent) {
23190        exponent = formatNumber(Math.round(exponent));
23191        var result = [];
23192        for (var i = 0, len = exponent.length; i < len; i++) {
23193            var cha = exponent.charAt(i);
23194            result.push(SUPERSCRIPTS[cha] || '');
23195        }
23196        return result.join('');
23197    }
23198    function aroundZero(val) {
23199        return val > -EPSILON && val < EPSILON;
23200    }
23201    return smartLogSteps;
23202});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.